简体   繁体   English

Github恢复错误“无法恢复提交”

[英]Github revert error “Unable to revert commit”

So I was trying to revert to a previous version of my program when it corrupted. 因此,当我的程序损坏时,我试图将其恢复为以前的版本。 Now, in my code I have various lines of code scattered throughout that are to the effect of: 现在,在我的代码中,各行代码分散在各处,从而达到以下效果:

<<<<<<< HEAD

=======
>>>>>>> parent of 410c297... "safe version"

=======

etc. When I try to revert to a previous point again, it says, "Unable to revert commit, (digits) (name) 等等。当我尝试再次还原到上一点时,它说:“无法还原提交,(数字)(名称)

I have a very basic understanding of the git terminal, so I can't really fix it myself. 我对git终端有非常基本的了解,所以我自己不能真正修复它。 Can I get some pointers? 我可以得到一些指示吗?

Reverting creates new commits that change existing committed files. 还原会创建新的提交,这些提交会更改现有的提交文件。 You've got a merge in progress, which means you can't revert. 您的合并正在进行中,这意味着您无法还原。

Most likely, you want to reset: you want to go back to an existing commit and pretend that you haven't done any work. 最有可能的是,您想重置:您想回到现有的提交,并假装您没有做任何工作。 The most common way of doing that is to get rid of all changes and in-progress merges by resetting to HEAD like this: 最常见的方法是通过像这样重置为HEAD来消除所有更改和进行中的合并:

git reset --hard HEAD

Afterwards, if you want to go back to an even earlier version, you can revert or maybe just checkout the older version. 之后,如果您想返回到更早的版本,则可以revert ,也可以只checkout出较旧的版本。 Or you can do both at the same time using the ~ notation: git reset --hard HEAD~3 means undo everything and go back 3 commits. 或者,您也可以使用〜表示法同时进行这两个操作: git reset --hard HEAD~3意味着撤消所有内容并返回3次提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM