I'd like to polish my (messy) feature branch a little before opening a pull request to the original repo. I have around 100 commits that I want to combine into 3 or 4. All commits are already pushed to my own remote repo. As I want to keep the many commits in my own repo, I created a new branch at the point where I forked the original repo. This branch is supposed to contain an exact copy of my work, but with fewer commits.
Unfortunately, merging my current HEAD into the new branch and applying rebase -i
fails at a merge commit (x
) and tells me that it could'nt apply the patch. Assume my history looks as follows:
o--o--o--o--o--o-----x
\ \
o--o--o--o--o
Any ideas how I can get past this commit?
If you’re on Git 2.34.0 or newer: use --rebase-merges
:
git rebase --interactive --rebase-merges
--preserve-merges
can’t be used any more.
That should work with git rebase -i -p commit
but at the expense of redoing that merge commit (that is, re-fixing the merge conflicts).
From the help:
-p, --preserve-merges try to recreate merges instead of ignoring them
However, in your case, just fixing the merge conflict and continuing the rebase could actually work.