I think other answers here are wrong, because this is a question of moving the mistakenly committed files back to the staging area from the previous commit, without cancelling the changes done to them.
(我认为这里的其他答案是错误的,因为这是一个将错误提交的文件从前一次提交移回到暂存区域的问题,而不取消对它们所做的更改。)
This can be done like Paritosh Singh suggested: (这可以像Paritosh Singh建议的那样完成:)
git reset --soft HEAD^
or
(要么)
git reset --soft HEAD~1
Then reset the unwanted files in order to leave them out from the commit:
(然后重置不需要的文件,以便将它们从提交中删除:)
git reset HEAD path/to/unwanted_file
Now commit again, you can even re-use the same commit message:
(现在再次提交,您甚至可以重用相同的提交消息:)
git commit -c ORIG_HEAD
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…