【发布时间】:2017-04-28 05:14:12
【问题描述】:
我在合并时遇到问题,但 git 没有将文件标记为冲突。
当我尝试使用git mergetool 打开文件时,git 只会说:No files need merging。
如何以三种方式比较打开文件而不发生合并冲突?
【问题讨论】:
-
你能详细说明你的合并问题吗?
标签: git git-merge merge-conflict-resolution
我在合并时遇到问题,但 git 没有将文件标记为冲突。
当我尝试使用git mergetool 打开文件时,git 只会说:No files need merging。
如何以三种方式比较打开文件而不发生合并冲突?
【问题讨论】:
标签: git git-merge merge-conflict-resolution
您可以执行以下操作:
git merge --no-commit topic
git checkout --merge that_file
git mergetool that_file
git commit
也就是说,你避免成功的合并创建一个提交,然后你假装that_file有冲突,那么你可以用git mergetool处理文件。最后,提交结果。
【讨论】:
git checkout 破坏对文件所做的更改?例如。在合并期间,我想再次打开一个 3 面板差异来帮助修复构建错误。
遗憾的是,我无法重现 @Filp Stefanov 的成功,所以我手工费力地完成了
(来自存储库根目录)
git merge --no-ff --no-commit <topic>
git show HEAD:<file> > <file>.ours
git show MERGE_HEAD:<file> > <file>.theirs
$(git config merge.tool) <file>.ours <file> <file>.theirs
rm <file>.ours <file>.theirs
git add <file>
git commit
大声说出来,
如果这基本上是 git 原生的功能,我不会感到惊讶
【讨论】:
git mergetool 使用 .gitconfig [merge] 部分中指定的工具
git mergetool --tool-help
查看此topic
将其中之一配置为 git diff 工具
例如:
git config --global diff.tool kdiff3
但据我所知,git diff 只能做 2-way diff。
解决方案是检查 3 个不同的目录并运行 kdiff3
【讨论】: