使用反向补丁在推后撤消 Git 提交?

我已经推送了一个提交,我想通过应用和提交一个反向补丁来恢复由这个提交引入的更改。我该怎么做?

79786 次浏览

Use

git revert HEAD

This will create a patch that reverts the last commit and commit that patch as a new commit.

If you want to revert a specific earlier version, use

git revert <revision>

see also: http://schacon.github.com/git/git-revert.html

simply use

for committed file:

git revert <SHA1 ID>

for non-committed file:

git reset --hard HEAD