GIT 单个文件中存在 2 个或多个合并冲突 - p4merge 如何处理?
- GIT p4merge - 同一文件中存在 2 个或更多冲突
我已将 p4merge 与 GIT 集成,并且曾经遇到过这种情况。
我有一个存在合并冲突的文件。文件说 foo.c 在 3 行不同的代码中存在合并冲突(第一行有冲突,中间的一些行有冲突)。
当我解决第一行冲突(不是其他冲突行)并保存(使用 p4merge 上的保存按钮)时,我猜它会将 foo.c 添加到索引,当我提交时,git 允许我提交而不会出现错误或警告以解决同一文件中的其他冲突行。
这是 GIT 或 p4merge 的问题吗?我认为 GIT 应该警告或错误指出该文件还有其他冲突的行。但它只是承诺。
- 在 GIT 中合并特定文件
我的另一个问题是是否有一个命令可以让我发送开发人员来合并某个文件?当我运行 git mergetool 时,它会一一打开所有合并冲突,而不是有一种像clearcase 这样的方法,我可以在其中合并这个选定的文件吗?
- GIT p4merge - 2 or more conflict in same file
I have integrated p4merge with GIT and i came across this situation once.
I have a file with merge conflicts. The file say foo.c has merge conflicts in 3 different lines of code (the first line with conflict, some lines in the middle with conflicts).
When i resolved the first lines of conflict (not other lines of conflict) and saved (using save button on p4merge) i guess it adds the foo.c to index, and when i commit, git allows me to commit without giving me an error or warning to resolve the other conflicting lines in the same file.
Is this an issue with GIT or p4merge? i think GIT should warn or error out that there are other conflicting lines that file. but it just commits.
- Merge specific file in GIT
The other question i have is is there a command so that i can send a developer to merge a certain file? When i run git mergetool it opens all merge conflict one by one, instead is there a way like clearcase where i can say merge this selected file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测:当您在 p4merge 中保存文件时,它会愉快地返回代码 0,文件已更改,并且 git 假定冲突已解决。有一个配置参数
mergetool..trustExitCode
(在您的情况下为mergetool.p4merge.trustExitCode
),可以将其设置为 false,因此 git 总是会询问运行 git mergetool 后合并是否成功(这可能很烦人)。您还可以为p4merge
编写一个包装器,它将在运行p4mege
或pre-commit
挂钩后检查冲突标记的存在,这拒绝包含包含此类标记的文件的提交,尽管我从未做过类似的事情。是的,您可以运行
git mergetool
来解析指定的文件。了解更多信息此处。My guess: when you save file in p4merge, it happilly return with code 0, file is changed, and git assumes that conflicts were resolved. There is a config parameter
mergetool.<tool>.trustExitCode
(mergetool.p4merge.trustExitCode
in your case), which can be set to false, so git will always ask you if merge was successfull after runninggit mergetool
(which can be quite annoying). You also might be able to write a wrapper forp4merge
which will check presence of conflict markers after runningp4mege
, orpre-commit
hook, which rejects commits containing files containing such markers, though I've never done something like that.Yes, you can run
git mergetool <file>
to resolve specified file. Learn more here.