Git 撤销错误

6

最近,我们项目的一个贡献者提交了一次破坏系统的更改。我正在尝试回滚到最新的可用版本:

我使用git log查找该提交:

commit 45359d69e7983946b233d9010f205be19ce8ebfe
Author:Tom
Date:   Mon Apr 14 14:59:50 2014 +0100

    Tweaks the interface to make it more clean

I then do:

git checkout 45359d69e7983946b233d9010f205be19ce8ebfe

接下来是:

git add -A && git commit -am "revert"

我最终尝试:

git push

它将返回:

 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'path'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

(在路径处,我只删除了服务器的URL)

有什么想法吗?

1个回答

7
要使用git撤销一个提交,请使用git revert $commit命令。它会创建一个新的提交,其中包含相反的更改(因此您将回到原始版本而不带有更改)。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接