Rolling back your most recent Git commit is very easy. Below are examples for two different scenarios.
Delete last commit and restore files to previous state:
git reset --hard HEAD~1
Delete last commit but keep files as they are:
git reset HEAD~1
Basically HEAD~1 is a pointer to the most recent commit.
Reset moves the pointer back to the previous commit, and adding
--hard restores the files as well.