Merging but overwriting changes in Git

John Hunt picture John Hunt · Jan 11, 2013 · Viewed 43.5k times · Source

When I merge a branch in Git to master I often get merge conflicts. Is there a way to merge a branch and just overwrite the stuff in the current branch?

Answer

kmkaplan picture kmkaplan · Jan 11, 2013

Add -X ours argument to your git merge command.

Say you are working in your local branch. Then you want to merge in what went in the master:

git merge -X ours master

On the other hand if you are in master and want to merge your local branch into master then @elhadi rightly says you should use theirs:

git merge -X theirs somebranch