Search code examples
gittortoisegit

Tool to resolve multiple merge conflicts in git using either "mine" or "theirs"


I have a situation where I am merging down changesets that have mutliple binary files in git. It is always the case where I will resolve the changes using either "Mine" or "Theirs". I have been using TortoiseGit for most of my day-to-day operations, but the merge conflict dialog, while allowing for multi-select, does not allow for multiple "resolve using theirs". It only ever resolves one file at a time.

Is there a tool that I could use for this specific situation (select 100+ files and resolve using theirs)?


Solution

  • If you are able to use the git command line program, you can specify the ours or theirs option to the recursive merge strategy to resolve all conflicts by selecting "our" changes or "their" changes, respectively.

    git merge -s recursive -X ours other-branch
    # or
    git merge -s recursive -X theirs other-branch
    

    (The recursive merge strategy is the default, so you probably don't have to include -s recursive; it is included above for completeness.)

    The full explanation is found in the git-merge documentation:

    The recursive strategy can take the following options:

    ours

    This option forces conflicting hunks to be auto-resolved cleanly by favoring our version. Changes from the other tree that do not conflict with our side are reflected to the merge result. For a binary file, the entire contents are taken from our side.

    This should not be confused with the ours merge strategy, which does not even look at what the other tree contains at all. It discards everything the other tree did, declaring our history contains all that happened in it.

    theirs

    This is the opposite of ours.