I had a local topic branch based off a remote branch on the git repo:
1 - 2 - 4 - 5 - 9 - 11 master
\
3 - 6 - 8 - 12 remote branch
\
7 - 10 my topic
The remote branch was recently rebased off master:
1 - 2 - 4 - 5 - 9 - 11 master
\
? 3' - 6' - 8' - 12' remote branch
\
7 - 10 my topic
I would like to rebase my topic branch off the head of the remote branch so that I can eventually merge my changes back into the remote. However, because the hash of the parent commit has changed, trying a simple
$ git rebase origin/remote_branch
results in a number of conflicts in files I’ve never touched.
Is there anything I can do to clean up these branches?
Simply rebasing on
origin/remote_branchis confusing for git because it tries to rebase outdated commits on the tip of remote_branch, which leads to duplicate commits and conflicts.Instead you must plug off and on, to the new point commit related to the sixth one, using the
--ontooption<6'-SHA>and<6-SHA>are respectively the new and old ids of the commit wheremy-topicwas created.