1

Here is my scenario:

[master]
  |
{c1}
 ||
 ||     [b']
 ||       |
 ||-----{c2'}
 ||       
 ||      [b'']
 ||        |
 ||-----{c2''}
 ||
 ||      [b''']
 ||         |
 ||-----{c2'''}


 {c?} - Commits
 b', b'', b''' - topic branches **(already on remote)**

A hotfix on master resulted master fast-forward like this:

            [master]
                |
{c1}----------{c2}
 ||
 ||     [b']
 ||       |
 ||-----{c2'}
 ||       
 ||      [b'']
 ||        |
 ||-----{c2''}
 ||
 ||      [b''']
 ||         |
 ||-----{c2'''}

To synchronize my topics b', b'' and b''' I know how to achieve one branch at a time ...I am looking for a better way to update all the branches simultaneously so that they appear to be diverging out of current master (or {c2}) instead of old master(or {c1})

Any pointers appreciated. Thanks

Vikram
  • 4,162
  • 8
  • 43
  • 65

1 Answers1

1

I think the answer @DavidM linked to is not applicable to your situation, because it shows how to rebase a number of branches at once, and your topic branches are already on the remote, so you can't rebase them at will.

I don't think you'll do any better than to simply merge master back in to each topic branch. That will bring the "hotfix" onto all the topic branches, and create new merge commits (so the history will show what you did). If you don't like the merge commits, just cherry-pick the "hotfix" onto each topic branch instead.

Alex D
  • 29,755
  • 7
  • 80
  • 126
  • thanks for your answer...I am looking at the quick script solution in that post by David: `for branch in topic1 topic2 topic3;do git rebase master $branch;done`. I don't get why you think that will not work?..Of course I will have topic branches checked out to my local before I run that script. This will have my local topic branches updated (rebased) and then I add one more line in the script to push it remote.. Do you think I am missing something here?...I'd like to hear...thanks for your time! – Vikram Aug 12 '13 at 15:53
  • +1 for the cherry-pick; accomplishes what the rebase would without messing with history of commits that have already been pushed. – antlersoft Aug 12 '13 at 16:11
  • @Vikram, it's not that the script "won't work" -- it will work, but when you try to push the topic branches back to the remote again, there will be problems. git will think that your local topic branches have diverged from those on the remote, and won't let you push the topic branches unless you first pull them. This will add redundant merge commits to your history, and worse, all the topic branch commits (`c2'`, etc.) will be duplicated in the history. – Alex D Aug 12 '13 at 21:22
  • `cherry-pick` option worked for me!..thanks @AlexD – Vikram Aug 13 '13 at 04:19