GIT 单个文件中存在 2 个或多个合并冲突 - p4merge 如何处理?

发布于 2024-09-30 10:02:23 字数 494 浏览 1 评论 0原文

  1. GIT p4merge - 同一文件中存在 2 个或更多冲突

我已将 p4merge 与 GIT 集成,并且曾经遇到过这种情况。

我有一个存在合并冲突的文件。文件说 foo.c 在 3 行不同的代码中存在合并冲突(第一行有冲突,中间的一些行有冲突)。

当我解决第一行冲突(不是其他冲突行)并保存(使用 p4merge 上的保存按钮)时,我猜它会将 foo.c 添加到索引,当我提交时,git 允许我提交而不会出现错误或警告以解决同一文件中的其他冲突行。

这是 GIT 或 p4merge 的问题吗?我认为 GIT 应该警告或错误指出该文件还有其他冲突的行。但它只是承诺。


  1. 在 GIT 中合并特定文件

我的另一个问题是是否有一个命令可以让我发送开发人员来合并某个文件?当我运行 git mergetool 时,它会一一打开所有合并冲突,而不是有一种像clearcase 这样的方法,我可以在其中合并这个选定的文件吗?

  1. 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.


  1. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

又怨 2024-10-07 10:02:23
  1. 我的猜测:当您在 p4merge 中保存文件时,它会愉快地返回代码 0,文件已更改,并且 git 假定冲突已解决。有一个配置参数 mergetool..trustExitCode (在您的情况下为 mergetool.p4merge.trustExitCode ),可以将其设置为 false,因此 git 总是会询问运行 git mergetool 后合并是否成功(这可能很烦人)。您还可以为 p4merge 编写一个包装器,它将在运行 p4megepre-commit 挂钩后检查冲突标记的存在,这拒绝包含包含此类标记的文件的提交,尽管我从未做过类似的事情。

  2. 是的,您可以运行git mergetool来解析指定的文件。了解更多信息此处

  1. 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 running git mergetool (which can be quite annoying). You also might be able to write a wrapper for p4merge which will check presence of conflict markers after running p4mege, or pre-commit hook, which rejects commits containing files containing such markers, though I've never done something like that.

  2. Yes, you can run git mergetool <file> to resolve specified file. Learn more here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文