Is there any way to specify to git to automatically resolve the conflicts for a pack of files by taking the remote version for each of them? For instance, to take the remote version of each files in a certain directory?
Asked
Active
Viewed 1.6k times
20
-
See SO answer **[git command for making one branch like another](http://stackoverflow.com/questions/4911794/git-command-for-making-one-branch-like-another/4912267#4912267)** for *all* the current possible ways to **simulate `git merge -s their`**. – VonC Sep 03 '12 at 07:59
2 Answers
19
git-merge seems to support only the "ours" strategy, where the result of a merge is the local version. And that only for the whole tree.
If you enter a conflicted state while doing a merge, you can use git-checkout's --theirs
with a path to retrieve files from the index.
Finally you can git-reset to force parts of the tree to a specific commit.
There's now also http://www.seanius.net/blog/2011/02/git-merge-s-theirs/ who basically recommends making a merge -s ours
and then reverse-apply the changes.

David Schmitt
- 58,259
- 26
- 121
- 165
-
10x David for the tip. It seems that git-checkout does the trick. Unfortunately, the --ours|--theirs options are not supported by my version of git :( seems like I have to do some updating... – Feb 09 '09 at 17:57
-
2If there is no --ours|--theirs option to git-checkout, you can use 'git show :2:full_path > file' for --ours (stage #2), and 'git show :3:full_path > file' for --theirs (stage #3). Or use 'git checkout-index --stage=2|3 -- file...' plumbing – Jakub Narębski Feb 10 '09 at 21:52
7
You can use recursive
strategy (-s) with theirs
option (-X). That is:
git merge -s recursive -X theirs source_branch

L. Holanda
- 4,432
- 1
- 36
- 44