Reputation: 5184
Consider a scenario where while merging a branch lets say feature
into master
(git megre origin/feature
) and after resolving conflicts, if someone pushes into the master branch again during this process. Now, we cannot push the merge into master as they have diverted again. I see these options in these scenarios.
git rebase origin/master
- This will screw up the whole merge history.git merge origin/master
- But now we have two merge commits in the history and the second one is in most cases unnecessary.Is there anything obvious I am missing which is cleaner and does not requires to redo the merge conflict work we just did?
Upvotes: 1
Views: 808
Reputation: 14723
I think that you may want to try the following command:
git pull --rebase=preserve
or following if the upstream is already fetched
git rebase -p origin/master
where the semantics of option --rebase
(according to the doc) is as follows:
When set to
preserve
, rebase with the--preserve-merges
option passed togit rebase
so that locally created merge commits will not be flattened.
However note that according to the doc of git rebase,
Merge conflict resolutions or manual amendments to merge commits are not preserved.
In order to avoid resolving conflicts again you can look into the usage of git rerere.
Upvotes: 2