Skip to content

Instantly share code, notes, and snippets.

@pgorod
Forked from tkersey/Undo a commit and redo
Created April 2, 2018 17:00
Show Gist options
  • Save pgorod/5700067b4ec4874bf54ac32ef0569b38 to your computer and use it in GitHub Desktop.
Save pgorod/5700067b4ec4874bf54ac32ef0569b38 to your computer and use it in GitHub Desktop.
Git: undo a commit and redo
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