Merging but overwriting changes in Git

GitConflict

Git Problem Overview


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?

Git Solutions


Solution 1 - Git

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

Solution 2 - Git

To overwrite your stuff in your branch and take their work, you should make

git merge -X theirs {remote/branch} --> example:origin/master

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJohn HuntView Question on Stackoverflow
Solution 1 - GitkmkaplanView Answer on Stackoverflow
Solution 2 - Gitelhadi dp ıpɐɥןǝView Answer on Stackoverflow