Delete a local Git branch

CLI

Git

Branch

Delete local

Luc B.

Git

Branch

Having several stale branches in a local git repository makes things cluttered. It's good practice to clear out branches as soon as they're merged.

Code Example

Use the -d flag to git branch to delete a branch.

# Delete local branch
git branch -d my-stale-branch

If the branch has not yet been merged into master, you may get this error: error: The branch 'my-stale-branch' is not fully merged. To resolve this, replace -d with -D to force deletion regardless of merge status.