Skip to content

Instantly share code, notes, and snippets.

@ianmariano
Last active December 18, 2015 21:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ianmariano/5851658 to your computer and use it in GitHub Desktop.
Save ianmariano/5851658 to your computer and use it in GitHub Desktop.
Quick Git plugin to close a branch (return you to master and clean up your remote and local topic branches) when merged in a pull request. Place on your path and chmod a+x it. Use: git close-branch branchname
#!/bin/bash
usage() {
echo "Usage $0 branchname"
exit 1
}
if [ -z "$1" ]; then
usage
fi
if ! git diff --quiet; then
echo "You have uncommitted changes."
exit 1
fi
git checkout master
git push origin :$1
git branch -D $1
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment