Merging changes from master into all branches using Git?
One possibility (not tested myself) would be:
- to establish a bare repo where you can push your master branch.
- have a post-receive hook (see githooks man page) on that bare repo which will then push master on every "feature" repo you want
- have a post-receive hook per feature repo to begin:
- a rebase of your feature branch on top of master (fine if you did not yet pushed your feature branch elsewhere)
- or a merge of master on your feature branch.
You will still need to get to your feature repo and check if the rebase or merge is not blocked due to some merge conflicts.
The following checks out each branch and does the merge
for BRANCH in $(ls .git/refs/heads);
do git checkout $BRANCH ;
git merge origin/master $BRANCH ;
done
If
- the branches which you want to merge the latest master commits into are not published AND
- you want all commits in master to be in the other branches
then you could simply rebase them onto master after master has been updated. This little script might work if you're using a Unix shell. It rebases each branch onto master.
for BRANCH in `ls .git/refs/heads`; do git rebase master $BRANCH; done