Force git always choose a newer version during merge?

Suppose I am merge git and there is a merge conflict.

My question is: how can I get git to always choose a newer version of the code in the conflict, so I won’t have to resolve the conflict manually?

+83
git merge conflict
Nov 27 '12 at 22:29
source share
2 answers

This is not a completely new version, but you can say that git always prefers the version in the current branch using git merge branch -X ours or prefers the version of the branch to be merged using git merge branch -X theirs .

From man git-merge :

our:

This parameter causes conflicting chunks to be automatically resolved using our version. Changes from another tree that do not conflict with our side are reflected in the result of the merger. For a binary file, all content is taken from our side.

them

This is the opposite of "ours."

+157
Nov 27 '12 at 22:34
source share

I use this

 git fetch --prune git reset --hard origin/master 
+15
Aug 10 '15 at 5:40
source share



All Articles