合并错误后,如何获得我的git合并冲突? [英] How do I get my git merge conflicts back after merging incorrectly?

查看:109
本文介绍了合并错误后,如何获得我的git合并冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图合并2个分支,他们中有很多更改,其中几个分支存在合并冲突。我使用 git mergetool 合并了这些文件,但后来我意识到我错误地合并了其中的几个文件。我基本上想回到那些情侣文件的冲突状态,所以我可以重新运行mergetool并纠正我的错误。我不想扔掉我的整个合并,因为它的大部分是正确的。



我试过重置到我的脑袋,然后做 git checkout -m other_branch - my_file 无济于事。我最终重置为HEAD,将文件从另一个分支中取出,然后在文件上执行 git add --patch ,只是将所需的文件分级。但是必须有更好的方法......首先,检查一下你是否在索引中有冲突的状态( >重新设置为HEAD之前),通过

  $ git ls-files --stage --abbrev my_file 

您应该得到以下内容:

  100644 257cc56 1 my_file 
100644 b7d6715 2 my_file
100644 5716ca5 3 my_file

如果你没有得到,你必须使用 git update-index ,比如,或者使用临时文件。如果你有,那么

  $ git checkout -m my_file 

应该可以工作(我已经检查了这个)。


I'm trying to merge 2 branches that have a lot of changes in them, several with merge conflicts. I merged the files using git mergetool, but I've subsequently realized that I merged a couple of them incorrectly. I basically want to go back to the conflicted state for those couple files, so I can re-run the mergetool and correct my errors. I don't want to throw away my entire merge, since most of it is correct.

I've tried resetting to my head and then doing git checkout -m other_branch -- my_file to no avail. I ended up resetting to HEAD, getting the file out of the other branch, and just doing git add --patch on the file, only staging what I wanted. But there must be a better way...

解决方案

First, check out if you have conflicted state in the index (before resetting to HEAD), via

$ git ls-files --stage --abbrev my_file

You should get something like the following:

100644 257cc56  1        my_file
100644 b7d6715 2        my_file
100644 5716ca5  3        my_file

If you don't get that, you would have to use git update-index, like Charles Bailey said, or use temporary files. If you have that, then

$ git checkout -m my_file

should work (I have checked this).

这篇关于合并错误后,如何获得我的git合并冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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