I started work on the master branch. Almost one year ago, I created another branch dev in which I made some changes. From that time on I continued work on dev branch. Now I want to merge dev into master which results in lot of conflicts. I want to merge dev into master by overwriting master branch's contents i.e. for any conflict that arises I want to keep dev branch's version of the code. How can it be done ?
You can specify the strategy option with -X
switch:
git checkout master
git merge -X theirs dev
A bit explanation. The -X theirs
means: Use recursive strategy with the merge but fallback to their changes if the strategy cannot resolve the conflict.
This is different from -s ours
(for some reason there's no -s theirs
) which would be a greedy take ours always solution to conflicts.
git-merge(1)
Merge Strategies section provides a deeper explanation on this.
You'll want to use a "merge using theirs" strategy, which is set using the -X flag
git checkout master
git merge -X theirs dev
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With