Skip to content

Instantly share code, notes, and snippets.

@jjsub
Created February 14, 2015 01:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjsub/54e1410ca0407cddf740 to your computer and use it in GitHub Desktop.
Save jjsub/54e1410ca0407cddf740 to your computer and use it in GitHub Desktop.
Undo a commit and redo
$ git commit ... (1)
$ git reset --soft HEAD~1 (2)
$ edit (3)
$ git add .... (4)
$ git commit -c ORIG_HEAD (5)
1 This is what you want to undo
2 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 "commit".
3 Make corrections to working tree files.
4 Stage changes for commit.
5 Commit the changes, reusing the old commit message. "reset" copied the old head to .git/ORIG_HEAD; commit with '-c ORIG_HEAD' starts with the log message from the old commit and allows you to edit it. 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