Skip to content

Instantly share code, notes, and snippets.

@anchoo2kewl
Last active August 29, 2015 14:01
Show Gist options
  • Save anchoo2kewl/3f281ee8e481dc6aa652 to your computer and use it in GitHub Desktop.
Save anchoo2kewl/3f281ee8e481dc6aa652 to your computer and use it in GitHub Desktop.
This is used to merge one branch with several other branches
#/bin/bash
# chkconfig: 2345 50 70
SUCCESS=0
FAILURE=1
#
if [ $# -lt 2 ]
then
echo "Usage: deploy.sh mergeFromBranch {ListOFmergeToBranches}"
exit $FAILURE
fi
# CHeck if branch exists
cd /Users/anshuman/Documents/projects/bnearest
for var in "$@"
do
count=`git branch | grep $var|wc -l`
if [ $count -eq 0 ]
then
echo "Branch $var not found"
exit $FAILURE
fi
done
echo "Branch names OK! Merging branches"
count=0
for var in "$@"
do
if [ $count -ne 0 ]
then
git checkout $var
git merge $branch
git push origin $var
else
git pull origin $var
branch=$var
fi
count=$((count+1))
done
git checkout $branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment