Search code examples
gitgithubmerge-conflict-resolution

How does github finds If two branches has conflict before actually merging them?


In the pull request option. Upon selecting two branch, github notifies if the two branches has any conflict. What is the command to find branch conflict?


Solution

  • git merge-tree

    To compute the merge results of 2 revisions without making real changes:

    git merge-tree $(git merge-base <rev1> <rev2>) <rev1> <rev2>
    

    The 2 revisions have at least 1 common ancestor. If there're conflicts, the marks like <<<<<<<, =======, >>>>>>> will be printed.

    Update: for binary file conflicts, the log includes lines like

    warning: Cannot merge binary files: <binary path> (.our .vs .their)