Git - 即使没有冲突,如何强制手动合并 [英] Git - how to force manual merge even if there is no conflict
问题描述
这个页面包含了一个详细的指南,介绍如何设置一个总是返回失败的合并驱动程序,从而实现手动合并。我已经尝试过为Windows调整该解决方案: 我将以下内容添加到我的 我将驱动程序更改为 ( ,并且在repo的根目录下创建了一个文件 不幸的是,它不起作用。我试图合并文件 我做错了什么吗?任何解决强迫手动合并问题的解决方案都是非常受欢迎的。 我试过这个: 创建一个合并驱动程序 为合并类型创建一个部分 创建.gitattributes文件: ,错误报告,因为我认为你想要它被报告: 我有git版本2.11.0.rc1.windows.1。我无法按照指定的顺序运行复杂的命令,它报告了一些语法错误。 This is a question which was asked many times over the years. I have found a number of answers, in particular this one: Git - how to force merge conflict and manual merge on selected file (@Dan Moulding) This page contains is a detailed guide how to set up a merge driver that would always return failure and thus make possible a manual merge. I have tried to adapt that solution for Windows: I added the following to my I changed the driver to ( and, at the root of the repo, created a file Unfortunately, it does not work. I tried to merge a file, Do I do anything wrong? Any solution to the problem of forcing manual merge is most welcome. tl;dr: I tried to repeat what you described and it seems to work. There were 2 changes compared to yours version but without them I have merge failed as well (because driver basically failed to run) I have tried this: Create a merge driver Create a section for the merge type Create the .gitattributes file: After that, error is reported as I think you want it to be reported: I have git version 2.11.0.rc1.windows.1. I was not able to make the complicated command as you specified run successfully, it was reporting some syntax errors. 这篇关于Git - 即使没有冲突,如何强制手动合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
%homepath% \.gitconfig
:
[mergeverify]
name =合并并验证驱动程序
driver =%homepath%\\merge-and-verify-driver.bat%A%O%B
cmd / Kecho工作> merge.log& git合并文件%1%%2 %% 3%& exit 1
echo工作> merge.log
被添加以检查驱动程序是否被调用)。
。 gitattributes
与以下行:
*。txt merge = verify
feature.txt
,并且,唉,合并成功完成。看起来这个驱动程序根本没有被调用,因为merge.log文件没有被创建。
$ HOME / bin / errorout.bat
:
exit 1
[mergeerrorout]
name = errorout
driver =〜/ bin / errorout.bat%A %O%B
*。txt merge = errorout
$ git merge a
C:\ ...> exit 1
自动合并f.txt
CONFLICT(内容):合并f.txt中的冲突
自动合并失败;修复冲突,然后提交结果。
%homepath%\.gitconfig
:[merge "verify"]
name = merge and verify driver
driver = %homepath%\\merge-and-verify-driver.bat %A %O %B
cmd /K "echo Working > merge.log & git merge-file %1% %2% %3% & exit 1"
echo Working > merge.log
was added to check whether the driver was invoked)..gitattributes
with the following line:*.txt merge=verify
feature.txt
, and, alas, the merge completed successfully. It seems that the driver was not invoked at all, since the merge.log file was not created.$HOME/bin/errorout.bat
:exit 1
[merge "errorout"]
name = errorout
driver = ~/bin/errorout.bat %A %O %B
*.txt merge=errorout
$ git merge a
C:\...>exit 1
Auto-merging f.txt
CONFLICT (content): Merge conflict in f.txt
Automatic merge failed; fix conflicts and then commit the result.