Delete a Git Branch Locally and Remotely
How to Delete a Git Branch Locally and Remotely: A Step-by-Step Guide
Published by Carlo van Wyk on June 15, 2025 in Git

Deleting Git branches locally and remotely requires different commands, but the process is straightforward.
Delete a Local Git Branch
To delete a local branch that has been merged, use:
git branch -d branch_nameThe lowercase 'd' is the "safe" delete that only works if the branch has been merged into the current branch or upstream branch. Git checks that you won't lose any commits before deleting.
To delete a local branch that has not been merged yet, force delete with:
git branch -D branch_nameThe uppercase 'D' is a "force" delete that bypasses all safety checks. It will delete the branch regardless of merge status, potentially causing you to lose commits that exist only on that branch.
Delete a Remote Git Branch
To delete a remote branch, use either of these equivalent commands:
git push origin --delete branch_nameor
git push origin :branch_nameVerify Branch Deletion
Check local branches:
git branchCheck remote branches:
git branch -rClean Up References
If deleted remote branches still appear in your local repository, update references with:
git fetch --pruneor
git remote prune origin