git - How can I check out multiple branches that match a prefix and run commands -


i have git repo has multiple releases branches.

what want create script list release branches match pattern, check out each of these branches in turn , run git merge master , push remote.

is there anyway without me typing branch name manually?

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

ps. script add set -e @ start , can remove && , || exit 1.


Comments