Git Merge Preference

Have a messy git merge, but know that one branch is ahead of the other and it should override the other? Use the merge -X strategy-option flag to tell it to show preference to ours, the current branch we’re on, or theirs, the branch we’re merging in. We can avoid having to resolve conflicts as git will intelligently do it for us using the strategy we passed in.

In this example the branch we’re on in the event of a conflict will be chosen as the code to bring in and there won’t be any conflict as git will resolve it for us.

git merge -X ours abc

In this example the branch we’re merging in (abc) the event of a conflict will be chosen as the code to bring in and there won’t be any conflict as git will resolve it for us.

git merge -X theirs abc

Read more about it here

Instagram Post