Skip to content

Instantly share code, notes, and snippets.

@dep-deprecated
Created July 22, 2016 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dep-deprecated/6dcec9d63005009f21c05b900293d13b to your computer and use it in GitHub Desktop.
Save dep-deprecated/6dcec9d63005009f21c05b900293d13b to your computer and use it in GitHub Desktop.
Merges master to a comma separated list of branches
#! /bin/bash
if [[ -z "$1" ]]; then
echo 'Merges master to branches'
echo 'mmt [branch],[branch],[branch]'
else
git fetch
IFS=', ' read -a array <<< "$1"
for((i=0;i<${#array[@]};i++))
do
echo '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-'
git checkout ${array[i]}
git pull origin ${array[i]}
echo '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-'
git merge origin/master
echo '---'
read -p "Conflicts? Press CTRL-C to abort... Otherwise [Enter] to push ${array[i]} to origin"
git push origin ${array[i]}
echo '-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-'
echo 'Moving on...'
done
echo 'Oh.. All done!'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment