How do you delete a branch in Git (local and remote)?

# delete a local branch (safe, only if merged)
git branch -d feature-login

# force delete a local branch (even if not merged)
git branch -D feature-login

# delete a remote branch
git push origin --delete feature-login

You cannot delete the branch you are on. Switch to another branch first. See Git Branch.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.