Dimitar Slavchev
Dimitar Slavchev

Reputation: 1667

Rebasing multiple branches simulteniously

First : In my case I am the only developer and pull, merge, etc.conflicts with other developers are not an issue at the moment.

I have a branch three that looks something like that. I have one master branch and multiple testing branches that are children of the master branch. However some of the changes I make need to be applied at the master branch and then all other branches are rebased with it so to have the same features/bugs as the master variant.

My usual workflow in this case is :

  1. I commit changes to the master

    git commit -as
    
  2. Then I have to go through all the other branches and rebase them with master.

    git checkout test_1
    git rebase master
    git checkout test_2
    git rebase master
    git checkout test_3
    git rebase master
    git checkout test_4
    git rebase master
    ...
    

Is there a way to automate that. I am on ubuntu and I use the bash shell.

Upvotes: 0

Views: 88

Answers (1)

CharlesB
CharlesB

Reputation: 90496

You can avoid checking out each branch by staying on master and do:

git rebase master test_2

For the rest a quick bash command does the job

for branch in test_1 test_2 test_N
do
   git rebase master $branch
done

Upvotes: 1

Related Questions