Delete a Git branch locally and remotely

git2

TL;DR Version

Delete Git branch locally (Be careful, your code or data will be lost)

# method 1
git push -d your_local_branch_name

# method 2
git push -D your_local_branch_name
  • -d is an alias for --delete, which delete only local branches
  • -D is the alias for --delete --force, even if this branch hasn't been merged or pushed.

Delete Git branch remotely (Be careful, your code or data will be lost)

git push origin --delete your_remote_branch_name

Normally origin is your remote repo (an alias for your full remote repo name), and it is the most cases when you are using online git service, such as github, bitbucket and so on.

Reference

comments powered by Disqus