Skip to content

Instantly share code, notes, and snippets.

@apoorvparijat
Forked from anonymous/git-reset-index
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save apoorvparijat/89fbd9930107fbf312da to your computer and use it in GitHub Desktop.

Select an option

Save apoorvparijat/89fbd9930107fbf312da to your computer and use it in GitHub Desktop.
What you need to do is to create a new commit with the same details as the current HEAD commit, but with the parent as the previous version of HEAD. git reset --soft will move the branch pointer so that the next commit happens on top of a different commit from where the current branch head is now.
# 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}
http://stackoverflow.com/questions/1459150/how-to-undo-git-commit-amend-done-instead-of-git-commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment