I currently have imported a huge project from SVN to Git.
I decided to flatten out all branches and keep only 2.
Master branch and Diverged branch.
Master: A-B-C-D
\ X-Y: Bugfix
Diverged: E-F-G-H
The diverged contains a lot of different source code, but some parts still originate from master. When we have to do some bugfixing we have to manually patch Master and Diverged on SVN. I would like to merge Bugfix into master (no problem here) and merge Bugfix into Diverged.
Keep in mind that i dont want the previous commits to be inserted into Diverged from master. So ABCD should be ignored.
The structure im looking for is this:
Master: A-B-C-D-X-Y
Diverged: E-F-G-H-X-Y
Could anyone help me figure this out?
Merging diverged branches is always painful.
First of all you have to remember some useful
gitcommands that will help you with a monster merge.git log HEAD..origin/master– will show you the differences between branches.If simple
git merge origin/masterdoes not work try to split the merge into a series of smaller tasks. I suggest rebasing your diverged branch on top of the current master, so that the changes will be localized:git rebase remotes/origin/masterYou will end up with a boring task of resolving each and every conflict (possibly in many commits), but these small tasks are much simpler then dealing with the whole merge at once.
After rebasing is complete you can fast-forward your master to the tip of the branch:
Empty commits will be omitted.
In the most complex scenarios you can use interactive rebase on your branch to rearrange the commits. I.e, for your scheme:
Though it is manual work but it is still a divide-and-conquer tactic.
Read this post for some in-depth ideas: http://blog.springsource.org/2010/12/21/git-and-social-coding-how-to-merge-without-fear/