Merging changes from master into all branches using Git?

假如想象 提交于 2019-11-30 08:46:53

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.

If

  1. the branches which you want to merge the latest master commits into are not published AND
  2. 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
3manuek

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!