Skip to content

Instantly share code, notes, and snippets.

@smurugap
Created November 25, 2015 00:46
Show Gist options
  • Save smurugap/a77c454b72cae21c1df4 to your computer and use it in GitHub Desktop.
Save smurugap/a77c454b72cae21c1df4 to your computer and use it in GitHub Desktop.
Accidental git amend on top of the Head
# Move the current head so that it's pointing at the old commit
# Leave the index intact for redoing the commit
git reset --soft HEAD@{1}
# commit the current tree using the commit details of the previous
# HEAD commit. (Note that HEAD@{1} is pointing somewhere different from the
# previous command. It's now pointing at the erroneously amended commit.)
git commit -C HEAD@{1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment