Skip to content

Instantly share code, notes, and snippets.

@RauliL
Created April 24, 2015 13:12
Show Gist options
  • Save RauliL/f007ae3df1492ada4f84 to your computer and use it in GitHub Desktop.
Save RauliL/f007ae3df1492ada4f84 to your computer and use it in GitHub Desktop.
#!/bin/sh
if test -z "${1}"
then
echo "Name of the branch missing."
exit 1
fi
if ! current_branch=`git rev-parse --abbrev-ref HEAD` 2> /dev/null
then
echo "No Git repository found."
exit 1
fi
if test "${current_branch}" = "master"
then
git pull origin master
else
git checkout master
git pull origin master
if ! git branch -d "${current_branch}"
then
exit 1
fi
fi
git checkout -b "${1}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment