0

I have a git repo which has multiple releases branches.

What I want to do is create a script that will list all release branches that match a pattern, check out each of these branches in turn and run a git merge from master and push it back to remote.

Is there anyway to do that without me typing the branch name manually?

orange
  • 5,297
  • 12
  • 50
  • 71
  • https://stackoverflow.com/questions/15292391/is-it-possible-to-perform-a-grep-search-in-all-the-branches-of-git-project – Igal S. Jul 26 '17 at 10:32

1 Answers1

0
for branch in `git branch --list prefix\*`; do
    git checkout $branch &&
    git merge master &&
    git push origin $branch || exit 1
done

PS. For a script add set -e at the start and you can remove && and || exit 1.

phd
  • 82,685
  • 13
  • 120
  • 165