Simon
Simon

Reputation: 602

How to merge all branches with the master branch?

I have a few branches locally and want to update them. How to merge the stuff from master branch into all other branches?

Upvotes: 1

Views: 706

Answers (2)

glenn jackman
glenn jackman

Reputation: 246807

Assuming that you branched off of master:

git checkout my_branch
git rebase master

Upvotes: 0

Simon
Simon

Reputation: 602

#!/bin/bash

git checkout master
git pull

branches=()
eval "$(git for-each-ref --shell --format='branches+=(%(refname))' refs/heads/)"

for branch in "${branches[@]}"; do
   branch=`expr substr $branch 12 100`
   git checkout $branch
   git merge master
done

git checkout master

Upvotes: 1

Related Questions