Skip to content

Instantly share code, notes, and snippets.

@shoaibi
Created June 25, 2015 15:35
Show Gist options
  • Select an option

  • Save shoaibi/9f75d1781380c6eeaa60 to your computer and use it in GitHub Desktop.

Select an option

Save shoaibi/9f75d1781380c6eeaa60 to your computer and use it in GitHub Desktop.
Remove a git branch
#!/bin/bash
origBranch=$(git rev-parse --abbrev-ref HEAD)
delBranch="$1"
E_BADARGS=65
if [ $# -ne 1 ]; then
echo "Usage: $0 {branch_name}"
exit $E_BADARGS
fi
git checkout "$delBranch" && git checkout "$origBranch" && git branch -D "$delBranch" && git push origin ":$delBranch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment