Skip to content

Instantly share code, notes, and snippets.

@chrismarksus
Created April 8, 2015 19:00
Show Gist options
  • Save chrismarksus/be89e191a7dcdf70d3d8 to your computer and use it in GitHub Desktop.
Save chrismarksus/be89e191a7dcdf70d3d8 to your computer and use it in GitHub Desktop.
Create a merge branch and merge master to feature branch script
#!/bin/bash
LOCAL=$1
REMOTE=$2
MERGE=origin/master
echo -e "\n\e[1;37mCreate new merge branch \e[1;34m$LOCAL\e[1;37m from '\e[0;32m$REMOTE\e[0m'\n"
git checkout -b $LOCAL $REMOTE
# get local and remote hashes
LHASH=$(git rev-parse $LOCAL)
RHASH=$(git rev-parse $REMOTE)
if [[ $LHASH = $RHASH ]]; then
echo -e "\e[1;37mLocal branch \e[1;34m$LOCAL\e[1;37m matches '\e[0;32m$REMOTE\e[1;37m', Merging master this branch!\e[0m"
git merge $MERGE
exit 0
else
# else fail
echo -e "\e[1;31mThe git rev-parse on one of the branches does not match!\e[0m\n"
echo $LHASH
echo $RHASH
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment