Last active
April 20, 2017 21:06
-
-
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
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
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