2

I can't make git push origin B. I have situation something like this

 _____________________________________ A
   \              
    \               _____origin/B
     \             /   
      \___________/____________.
                               B\
                                 \______________
                                                C

Git suggests me, to do

git rebase origin/B

Is this dangerous for branch C?

Should I earlier rebase C onto some temporary place?

noisy
  • 6,495
  • 10
  • 50
  • 92
  • Which branch can't you push? Which branch are you thinking of rebasing against origin/B? Is it the local branch B? – Ben James Sep 14 '10 at 14:56
  • yes, B and origin/B are logical this same. Moreover, I can modify history on origin. – noisy Sep 14 '10 at 15:02
  • See also [how I'd rebase a whole subhistory -- several branches, with some links between them resulting from merge](http://stackoverflow.com/a/9706495/94687). The unpleasant part of that solution is the need to reset the topic branch refs to the new rebased commits afterwards. – imz -- Ivan Zakharyaschev Mar 14 '12 at 22:06

2 Answers2

2

Rebase rewrites the history. If you rebase B onto origin/B, you'll then have to rebase C onto B.

mipadi
  • 398,885
  • 90
  • 523
  • 479
2

Rebasing B won't affect any of the commits in C. The history going back from C will still contain the same commits with the same hashes; it just won't contain the branch head B any more.

The commits that currently shared by B and C will be duplicated (content-wise; the hashes will change) when creating the new history for B.

You will end up with:

 _____________________________________ A
   \              
    \               _____origin/B_____ B
     \             /   
      \___________/____________._______C
Ben James
  • 121,135
  • 26
  • 193
  • 155
  • If you want to avoid the duplicate commits, you could then do `git rebase --onto B C`. You could also avoid making a mess by merging instead of rebasing. – Cascabel Sep 14 '10 at 18:19