In this case, you didn't configure a merge strategy, you configured a merge driver:
A merge strategy is a program that determines how two (or more) commits are merged. By default, git merge
uses the "recursive" strategy, found in the program git-merge-recursive
. By specifying the --strategy <strategy>
flag to git-merge
(or git-pull
) you tell it to invoke a different strategy. If you want to plug in your own merge strategy, you can, by creating an executable git-merge-mystrategy
in your path and running git merge --strategy mystrategy
.
This is different than a merge driver. A merge driver is the mechanism used to resolve a conflict on a file that exists when merging two commits. You plug in your own merge driver in the manner you outlined, by configuring a merge.mydriver.driver
setting.
To enable your merge driver for a particular file, you need to configure the driver for that file in .gitattributes
:
filename merge=mydriver
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…