更新时间:2022-12-30 11:29:10
首先,如果您认为自己的分辨率(或部分分辨率)不错,请将文件复制到其他位置. :-)然后运行:
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.