Skip to content

Instantly share code, notes, and snippets.

Last active September 13, 2020 12:50
What would you like to do?

To delete any branch, you shouldn't be on that branch, so switch to another branch before giving the commands

To delete any branch run,

git branch --delete <branch_name>
git branch -d <branch_name>

But this fails if the branch hasn't been merged, so to force delete, if required, run,

git branch --delete --force <branch_name>
git branch -D <branch_name>

To delete the remote branch, you need to run,

git push origin --delete <branch_name>
git push origin :<branch_name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment