4 exists_local=$(git branch | grep -x " $branch_name" | wc -l)
5 exists_remote=$(git branch | grep -x " origin/$branch_name" | wc -l)
7 if [[ $exists_remote -eq 0 ]] ; then
8 # Make sure we have the latest origin/stable to branch
10 # Specifying stable to get the last released code
11 git checkout -b "$branch_name" origin/stable
12 # Go ahead and put the branch out on the server
13 git push origin "$branch_name"
14 # Setup the merge property so that pulls come from the right place (instead of stable)
15 git config --replace-all "branch.$branch_name.merge" "refs/heads/$branch_name"
17 if [[ $exists_local -eq 0 ]] ; then
18 # Make sure we have the latest origin/$branch_name to branch
21 git checkout -b "$branch_name" "origin/$branch_name"
24 git checkout "$branch_name"