Created
February 9, 2012 15:16
-
-
Save mezis/1780617 to your computer and use it in GitHub Desktop.
Close a feature branch - removing it from local and remote
This file contains hidden or 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
#!/bin/bash | |
# | |
# Close a feature branch - removing it from local and remote. | |
# | |
die() { | |
echo "$@" ; exit 1 | |
} | |
head=$(git symbolic-ref HEAD 2> /dev/null || git log -1 --format=%h) | |
current_branch=${head#refs/heads/} | |
branch="$1" | |
: ${branch:-$head} | |
echo "Closing feature branch $branch" | |
if [ "$branch" = "$current_branch" ] ; then | |
git checkout master || die | |
fi | |
git branch -d "$branch" || die | |
git push origin ":$branch" || die |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment