Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Husterknupp
Last active April 20, 2017 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Husterknupp/db4b9d8b9a22066208542546e4d67ca5 to your computer and use it in GitHub Desktop.
Save Husterknupp/db4b9d8b9a22066208542546e4d67ca5 to your computer and use it in GitHub Desktop.
git checkout to develop branch and remove branch that just became obsolete. aanand/git-up required
git_checkout_and_forget() {
git_status=$(git status)
if [[ $? -eq 0 ]]; then
current_branch=$(git status | awk '/On branch/ {print $3}')
if [[ -z "$1" ]] ; then
checkout="develop"
else
checkout=$1
fi
git checkout $checkout
git up
if [[ -z "$2" ]] ; then
else
if [ "$2"=="--keep" ] ; then
else
echo 'delete branch' $current_branch
git branch -d $current_branch
fi
fi
else
# no .git directory - git will prompt something
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment