Git branch redirects with united children

Today I ran into one problem. My teammate created a branch from the master. He developed one feature in this branch, and then developed two subelements in subfehal branches. Finally, he did two refactoring. So that...

C--D E--F | subfeatures / \ / \ B------M1------M2--G--H | feature / A-------------------K | master 

Usually we rebuild function branches before merging to master without redirection. But, of course, this relocation failed. The deferred function branch looked like this:

  B'--C'--D'--E'--F'--G'--H' / A--K 

Of course, the pointers to C and D became wrong, so I also get two subfederal branches growing “out of thin air”. I understand how to fix this if the sub-branch branches were not merged into a function, but at that time I was confused. I cherry took everything in the restored recovery branch and merged everything again. Is this an easier way to do this?

+11
git branch merge rebase
source share
2 answers

Note that you need git1.7.6 + for git rebase --preserve-merges .

  • a rebase --preserve-merges --onto didn't work before (" git rebase --preserve-merges --onto doesn't save merges ")
  • a rebase --preserve-merges a problem:

In short: you just finished the merge, and someone pressed the commit before you could click on yours. The solution is to make git aware of the merge you made.

 git rebase --preserve-merges <upstream> 

or

 git rebase -p <upstream> 

But there is a problem if in your merger there are conflicts that you have solved, they will not be picked up by the reinstallation mechanism.
And you will resolve conflicts again ... at least this is the case with git version 1.7.5.4

(This will invoke git rerere )

+14
source share

Have you been a scoop to do each one by one manually?

Just run git rebase -i master feature and rewrite the story as you like.

+2
source share

All Articles