What is the default behaviour of "Resolve using theirs" in git

1.2k Views Asked by At

As per this question, I know it is possible to keep all changes that did not raise any conflict, while using theirchanges for the conflicting changes.

What I would like to know is, when using SourceTree (or, if relevant, any git tool or even the command line), what is the default behaviour when choosing Resolve using theirson a single file (or even the complete merge).

  • Does it simply replace the complete local file with whatever is in the remote ?
  • Does it keep all the local non conflicting changes and only use theirs for all the conflicts?
2

There are 2 best solutions below

0
On BEST ANSWER

It resolves the non conflicting changes and prefers theirs for conflicting ones. (The opposite for ours)

From man

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.

    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 opposite of ours.
0
On

Sadly, if a file conflicts and you choose "resolve using theirs" for it, Git will replace the complete local file with theirs, instead of only the conflict lines.