How to get 3-way merge in GIT on non-conflict merges?

前端 未结 2 1932
忘掉有多难
忘掉有多难 2020-12-17 02:56

How to disable auto-merging in GIT?

The purpose is to have the same behaviour as for conflict merges resolution in automatic merges during invocatio

2条回答
  •  囚心锁ツ
    2020-12-17 03:33

    The trick is, the way git solves merges is:

    • always based on a 3-way merges (since the graph of commits allows to get a common ancestor very easily)
    • always seamlessly except for conflict (where the process gets assisted by you)

    So even if you define a merge driver, it won't kick in unless there is a conflict of some sort.


    The first setting to try is to define a merge attribute Unset

    Unset

    Take the version from the current branch as the tentative merge result, and declare that the merge has conflicts. This is suitable for binary files that does not have a well-defined merge semantics.

    You would write in a .gitattributes file

     * -merge
    

    , and see if that is enough to trigger the mergetool on all merged files.


    One reason this "unset" feature is not directly an option of git merge, is that:

    • merge is the main feature of a DVCS
    • merge is done at the tree level (considering the all project)

    Trying to unset the 3-way merge at the file level is not part of that merge process (which, again, reason at the tree level).
    So it is more suited as an attribute which can be set for a specific set of files.

提交回复
热议问题