您需要做的是创建一个新提交,其详细信息与当前HEAD提交相同,但其父级为的早期版本HEAD。git reset --soft将移动分支指针,以便下一次提交发生在与当前分支头所在位置不同的提交之上。# 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.)git commit -C HEAD@{1}