解决冲突后如何将文件移回冲突状态? [英] How to move a file back into the conflict state after conflict resolution?

查看:138
本文介绍了解决冲突后如何将文件移回冲突状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确实有一个解决冲突的漏洞专家,我认为我会继续努力,如果失败了,那么我应该能够将文件恢复为冲突状态.但是,我似乎找不到回溯的方法. git仍处于MERGING状态,那么如何备份单个文件并重新解析?

I have a real bugger of a conflict resolution set, and I figured that I'd just go for it and if I failed, then I should be able to bring back the file into its conflict state. However, I can't seem to find a way to go back. git is still in MERGING state, so how do I backup a single file and reresolve?

推荐答案

首先,如果您认为自己的分辨率(或部分分辨率)不错,请将文件复制到其他位置. :-)然后运行:

First, if you think you might have a decent resolution (or part of it), copy the file somewhere else. :-) Then just run:

git checkout -m -- path

(仅当文件的 path 类似有效的git checkout选项时,才需要--部分,例如,如果要放回冲突状态的文件命名为-f等.这将从三个输入(合并基础和两个分支头)重新创建文件的冲突标记变体,并将该文件写入工作树.

(the -- part is needed only if the file's path resembles a valid git checkout option, e.g., if the file you want to put back in conflicted state is named --theirs or -f or some such). This will re-create the conflict-marker variant of the file from the three inputs (merge base and both branch heads), and write that file to the work-tree.

请注意,您可以指定--conflict=merge(默认)样式或--conflict=diff3样式.这与在.gitconfig中设置merge.conflictStyle相同,但仅针对该一个文件和该一次检出.

Note that you can specify the --conflict=merge (default) style, or the --conflict=diff3 style. This is the same as setting merge.conflictStyle in .gitconfig, but just for that one file and this one checkout.

如果您(或git mergetool)使用已在已解决变体上运行git add的合并工具,请注意,这会使文件返回冲突状态,即,它将三个较高级的条目还原到索引中.现在,您可以再次运行git mergetool,或者-我个人喜好-只要确信正确无误,就可以手动编辑有冲突的文件并git add生成的工作树副本.

If you (or git mergetool) used a merge tool that already ran git add on the resolved variant, note that this puts the file back into conflicted state, i.e., it restores the three higher stage entries into the index. You can now run git mergetool again, or—my personal preference—just manually edit the conflicted file and git add the resulting work-tree copy once you are satisfied that it is correct.

这篇关于解决冲突后如何将文件移回冲突状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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