我正在尝试将 BeyondCompare4 配置为 git 中的 difftool 和 mergetool。我正在使用 git 版本 2.5.0.windows.1。到目前为止,BeyondCompare4 作为 difftool 工作得很好,但不能作为合并工具。
从我的主分支运行git mergetool branch3,它响应No files need merging
但是当我运行时,git diff branch3我可以在一个文件中看到几种类型的差异(通常在同一行)。如果我只是运行git merge branch3它,它确实会启动合并过程并以 CONFLICT 停止。那么为什么不git mergetool以同样的方式为我工作呢?
此链接建议git config --global core.trustctime false我尝试失败:
git mergetool 报告“没有文件需要合并”
此链接表明 rerere 可能有问题,所以我git config --global rerere.enabled false也尝试过,但没有运气:
git 告诉我我合并冲突,但也告诉我没有文件需要合并
这是我的 .gitconfig 的样子:
[diff]
tool = bc
[difftool]
prompt = false
[difftool "bc"]
trustExitCode = true
cmd = 'c:/program files (x86)/beyond compare 4/bcomp.exe' $LOCAL $REMOTE
[merge]
tool = bc
[mergetool]
prompt = false
[mergetool "bc"]
trustExitCode = true
cmd = 'c:/program files (x86)/beyond compare 4/bcomp.exe' $LOCAL $REMOTE $BASE $MERGED
Run Code Online (Sandbox Code Playgroud)
我什至尝试修改 .gitconfig 以将 bcomp4.exe 路径更改为虚假的内容,只是为了查看是否会出错。如果我对 difftool 进行更改,我会收到有关系统找不到路径的错误。但是,如果我在 mergetool 上更改它,它只会一直说“没有文件需要合并”,这让我相信 BeyondCompare4 甚至没有运行。
感谢您提供为什么git mergetool要提前停止该消息的任何想法。
git mergetool当您处于需要解决冲突的状态时,即合并导致冲突后,您应该使用。
git checkout master
git merge branch3
# the merge reports conflicts which we need to resolve
git mergetool
git add -u
git commit -m "a merge commit message"
Run Code Online (Sandbox Code Playgroud)
有关使用 meregetool 解决冲突的更多信息,请访问https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#Basic-Merge-Conflicts
咨询git help mergetool选项。