仍然有冲突,但git说:“没有文件需要合并” [英] Still have conflicts but git says "No files need merging"

查看:734
本文介绍了仍然有冲突,但git说:“没有文件需要合并”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两台笔记本电脑,每台都在主分支上工作。今天早上,我忘记了在其他笔记本电脑上工作之前对分支进行的更改。所以我有两种不同的代码版本。所以我推出了第二台笔记本电脑的代码,然后在第一台笔记本电脑上尝试并将该版本合并到远程版本中。



我尝试合并,但我认为我搞砸了。我有以下代码:

 < HEAD 
.publicHome-input-neutral {
=======
.signin-input {
>>>>>>> fae264c582726a42c3d09f2ffbbe5b429a471598
line-height:40px;
height:40px;
font-size:18px;
padding:0px 16px;
border:1px solid @ color-instanty-blue;
border-radius:6px;
背景:#ffffff;
text-align:center;
width:250px;
颜色:@ color-text-dark;
}

<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
=======
.signin-input.ng-invalid {
border-color:red;
}

正如你所看到的,它仍然很混乱。我安装了p4merge,并尝试通过 git mergetool 来启动它。我收到了没有文件需要合并的消息



在我搞垮合并之前,能否恢复到早期阶段?或者以某种方式解决这些错误合并的文件?

解决方案

听起来好像您在文件中使用git冲突符号添加了+ 。这本身并不是一个大问题(我们都已经完成了)。你有两个主要的选择,我看到它:



1)按照<<<,= ===,>>>>,然后手动评估并修复每个冲突,然后简单地提交这些更改。

2)在合并之前恢复。要做到这一点,只需输入 git log ,并找到执行合并的提交并将该提交的SHA复制到剪贴板,然后输入:



git revert -m 1 <您的SHA在这里>



然后执行再次合并,但这次在输入 git add 之前确保所有的git冲突符号,因为这个命令表明你已经解决了冲突。



PS。如果你想看看你将要恢复的提交,在实际执行还原之前,只需输入 git checkout<你的SHA在这里> 并浏览一下。一旦你满意这是你想要的地方,请输入 git checkout master 以回到原来的位置。


I have two laptops, each work on the master branch. This morning I forgot to push changes made to the branch before working on the other laptop. So I have two different versions of code. So I pushed the code from the second laptop and then on the first laptop was going to try and merge that version into the remote version.

I tried to merge but I think I screwed it up. I have the following code:

<<<<<<< HEAD
.publicHome-input-neutral {
=======
.signin-input {
>>>>>>> fae264c582726a42c3d09f2ffbbe5b429a471598
    line-height: 40px;
    height: 40px;
    font-size: 18px;
    padding: 0px 16px;
    border: 1px solid @color-instanty-blue;
    border-radius: 6px;
    background: #ffffff;
    text-align: center;
    width: 250px;
    color: @color-text-dark;
}

<<<<<<< HEAD
=======
.signin-input.ng-invalid {
    border-color: red;
}

As you can see it's still messy. I have p4merge installed and tried starting it via git mergetool. I got the message though No files need merging.

Can one revert to earlier stages before I screwed up the merge? Or somehow resolve these files which where wrongly merged?

解决方案

It sounds like you added + committed changes with git conflict notation in the files. This in itself is not a huge issue at all (we've all done it). You have two main options, as I see it:

1) Search your files for patterns along the lines of "<<<<", "====", ">>>>" and manually assess and fix each conflict, then simply commit these changes.

2) Revert to before you merged. To do this simply enter git log, and find the commit where you performed the merge and copy the SHA of that commit to your clipboard, then enter:

git revert -m 1 <your SHA here>

Then perform the merge again, but this time make sure all of the git conflict notation before entering git add, as this command indicates that you have resolved the conflicts.

PS. If you want to look at the commit you're about to revert to, before actually performing the revert, simply enter git checkout <your SHA here> and have a look around. Once you're satisfied that this is where you want to be, enter git checkout master to get back to where you were.

这篇关于仍然有冲突,但git说:“没有文件需要合并”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆