You could try using the ours
merge strategy:
git checkout dev
git merge -s ours master
git checkout master
git merge dev
The merge to master will create a merge commit, but the result of the commit will ignore all changes made in master
. Then you simply fast-forward master
to match dev
.
From the documentation for merge strategies:
ours
This resolves any number of heads, but the resulting tree of the merge is always that of the current branch head, effectively ignoring all changes from all other branches. It is meant to be used to supersede old development history of side branches. Note that this is different from the
-Xours
option to the recursive merge strategy.