Monday, December 23, 2013

BASH scripting GIT branch creation

This creates a develop branch if it doesn't exist already

create_develop_branchifNotExists() {

if git show-ref --verify --quiet "refs/heads/$branch"; then
#echo >&2 "Branch '$branch' exists."
echo ""
#read -p "Do you really want to create branch $branch " ans
#echo $ans
echo "Creating $branch branch"
git branch $branch
git branch -a #show all branches

# And the following lines assume you've already checked in all your changes. It will switch to develop branch and merge your changes from master into develop branch and go back to master branch.

echo "========== MERGING Current branch into develop branch ============="
git checkout develop
git merge master

git checkout master

No comments: