git: How do I add a custom merge strategy?

前端 未结 1 1076
执念已碎
执念已碎 2020-12-01 09:43

I\'m trying to add a custom merge strategy similar to the one in this question: Git merge conflict to always take the newest file

I\'ve saved the script as git

相关标签:
1条回答
  • 2020-12-01 10:04

    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
    
    0 讨论(0)
提交回复
热议问题