How to Delete a Local Branch in Git
Managing branches is a core part of working with Git, and knowing how to clean them up is just as important as knowing how to create them. Local branches can accumulate quickly — feature branches, experiment branches, hotfix branches — and deleting the ones you no longer need keeps your repository tidy and your workflow clear.
What Is a Local Branch in Git?
A local branch exists only on your own machine. It's separate from a remote branch, which lives on a server like GitHub, GitLab, or Bitbucket. When you delete a local branch, you're only removing it from your local Git environment — the remote version (if one exists) stays completely untouched.
This distinction matters. Many developers accidentally assume deleting a local branch removes it everywhere. It doesn't. Remote branches require a separate deletion command.
The Basic Command to Delete a Local Branch
Git provides two flags for deleting a local branch, and which one you use depends on the state of that branch.