# Move the current head so that it's pointing at the old commit# Leave the index intact for redoing the commit.# HEAD@{1} gives you "the commit that HEAD pointed at before# it was moved to where it currently points at". Note that this is# different from HEAD~1, which gives you "the commit that is the# parent node of the commit that HEAD is currently pointing to."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.)# The -C option takes the given commit and reuses the log message and# authorship information.git commit -C HEAD@{1}
git reset --soft <SHA BEFORE THE AMMEND>#you now see all the changes in the commit and the amend undone
#save ALL the changes to the stashgit stash
git pull origin <your-branch> --ff-only#if you issue git log you can see that you have the commit you didn't want to amend
git stash pop#git status reveals only the changes you incorrectly amended
#now you can create your new unamended commit