[Git] Delete a local branch with git branch -d

Created on November 30, 2026

Use git branch -d to delete a local branch after its work has been merged.

git branch -d feature-branch

Git shows the abbreviated hash of the branch's former tip.

Deleted branch feature-branch (was 0123456).

-d checks whether the tip is merged into the branch's upstream, or into HEAD if there is no upstream. It refuses deletion when the check fails.

-D is short for -d --force and can delete a branch whose commits have not been merged.

git branch -D feature-branch

Switch away from a branch before deleting it.

Reference

Git