Skip to content

Instantly share code, notes, and snippets.

@saintsGrad15
Created October 5, 2017 14:31
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 saintsGrad15/eee2a70c214e08c55697d61659bbdbd4 to your computer and use it in GitHub Desktop.
Save saintsGrad15/eee2a70c214e08c55697d61659bbdbd4 to your computer and use it in GitHub Desktop.
A function to delete a branch from git both locally and on the remote
function deleteBranch()
{
git branch -d "$1"
if [ $? -ne 0 ]; then
echo "Trying with -D"
git branch -D "$1"
fi
if [ $? -ne 0 ]; then
echo "Cannot delete branch"
else
git push origin ":$1"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment