Git: Undo the last commit
Run git reset HEAD~
or alias it to git undo
.
Bonus: how to use the commit message from the undoed commit.
Undo the last/previous/most recent commit:
git reset HEAD~
Afterwards, to use the commit message from the undoed commit:
# -C <commit>
# --reuse-message=<commit>
#
# Take an existing commit object,
# and reuse the log message and the authorship information (including the timestamp)
# when creating the commit.
#
# -c <commit>
# --reedit-message=<commit>
#
# Like -C, but with -c the editor is invoked,
# so that the user can further edit the commit message.
git commit -c ORIG_HEAD
If using my git aliases:
git undo
# Use the commit message from the undoed commit
git redo