Reputation: 4360
I normally pull my coworker's feature branch when it's ready to merge into master, but first I rebase it on top of the latest master and squash down the work-in-progress commits into a single commit (my coworker is a designer and uses a GitHub GUI).
I ran into an issue when my coworker had included in his feature branch a merge commit from master. The problem is, he included feature changes in his merge commit that were getting removed during the rebase. As far as I know, git rebase master
normally ignores merge commits, and git rebase --preserve-merges master
wasn't doing any rebasing all.
I came across various solutions for generating a patch, but most of them either omitted the merge commit or omitted some needed binary files. I finally came up with this solution:
git checkout master
git diff --binary master...feature-branch > my.patch
git apply -3 my.patch
git commit
rm my.patch
Is there a better way to do this?
Upvotes: 0
Views: 151
Reputation: 4360
This generates a file called my.patch
, applies it using a 3 way merge, commits the changes, then removes the patch file.
git checkout master
git diff --binary master...feature-branch > my.patch
git apply -3 my.patch
git commit
rm my.patch
Upvotes: 1