Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using git, how to do a 'use theirs' during a conflict?

Tags:

git

merge

With git, how do I do a "use theirs" type branch merge command? This command should just overwrite my local version with the origin's version.

like image 547
mrblah Avatar asked Dec 01 '09 02:12

mrblah


People also ask

What is theirs in Git?

The 'ours' in Git is referring to the original working branch which has authoritative/canonical part of git history. The 'theirs' refers to the version that holds the work in order to be rebased (changes to be replayed onto the current branch).


1 Answers

To replace your master with origin's master:

$ git checkout master
$ git branch -M master old-master
$ git checkout --track -b master origin/master

The git-merge manpage defines the 'ours' strategy as (emphasis added)

MERGE STRATEGIES

ours
This resolves any number of heads, but the result of the merge is always the current branch head. It is meant to be used to supersede old development history of side branches.

If you want a remote branch to win, create a tracking branch, check it out, and git merge -s ours ... from there.

like image 51
Greg Bacon Avatar answered Sep 19 '22 16:09

Greg Bacon