Git扭转错误

Dar*_*rio 5 git

最近,我们项目的一个贡献者做了一个破坏我们系统的提交.我想恢复到最新的工作版本:

我使用git log来查找提交:

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

    Tweaks the interface to make it more clean
Run Code Online (Sandbox Code Playgroud)

然后我做:

git checkout 45359d69e7983946b233d9010f205be19ce8ebfe
Run Code Online (Sandbox Code Playgroud)

其次是:

git add -A && git commit -am "revert"
Run Code Online (Sandbox Code Playgroud)

我终于尝试:

git push
Run Code Online (Sandbox Code Playgroud)

哪个回报:

 ! [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.
Run Code Online (Sandbox Code Playgroud)

(它说道路我只删除了服务器的URL)

有什么想法吗?

kni*_*ttl 6

要使用git恢复提交,请使用git revert $commit.它将创建具有相反更改的新提交(因此您将返回原始版本而不进行更改).