Created
March 18, 2014 23:06
-
-
Save rjocoleman/9631735 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Aliased as $ git c | |
# $ git config --global alias.c qa-checkout | |
# checks to see if checkout -b is happening | |
# if it is and it fails because the branch already exists | |
# prompt to delete the existing branch | |
if [[ $1 == '-b' ]] | |
then | |
git checkout $@ | |
status=$? | |
if [ $status -eq 128 ]; then | |
while true; do | |
read -p "Do you want to delete the branch $2? " yn | |
case $yn in | |
[Yy]* ) git branch -D $2 && git checkout $@; break;; | |
[Nn]* ) exit;; | |
* ) echo "Please answer yes or no.";; | |
esac | |
done | |
fi | |
else | |
git checkout $@ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment