git reset allow us to undo a commit.

The following command undo the last commit:

git reset HEAD~

Then edit and add the files again.

You can use git commit -c ORIG_HEAD to create a new commit with the same message, because the reset command copy the old message to .git/ORIG_HEAD.

HEAD

HEAD~1 is a reference to the previus current version. It is the same as HEAD^.


👉 StackOverflow: undo a commit

👉 StackOverflow: explanation about HEAD