Created
October 8, 2010 22:36
-
-
Save tkersey/617683 to your computer and use it in GitHub Desktop.
Git: undo a commit and redo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/927358/git-undo-last-commit | |
Undo a commit and redo | |
$ git commit ... | |
$ git reset --soft HEAD^ (1) | |
$ edit (2) | |
$ git commit -a -c ORIG_HEAD (3) | |
This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message, or both. Leaves working tree as it was before "reset". | |
Make corrections to working tree files. | |
"reset" copies the old head to .git/ORIG_HEAD; redo the commit by starting with its log message. If you do not need to edit the message further, you can give -C option instead. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was super useful but beware that if you had files unstaged during the original commit they will be committed with the
commit -a
.