How to Delete Any Branch in Git: Local, Remote, and Everything In Between
Git branches are cheap to create and essential to modern development workflows — but they pile up fast. Knowing how to delete them cleanly, and understanding what actually happens when you do, saves you from cluttered repositories and the occasional panic when something disappears unexpectedly.
What a Git Branch Actually Is
Before deleting anything, it helps to know what you're removing. A Git branch isn't a copy of your code — it's a lightweight pointer to a specific commit. Deleting a branch doesn't destroy the commits it pointed to (at least not immediately). It removes the pointer itself, which means the commits become unreferenced and will eventually be cleaned up by Git's garbage collection.
This distinction matters because it affects how reversible a deletion is, and what risks you're actually taking.
Deleting a Local Branch
A local branch exists only on your machine. This is the most common deletion you'll perform, typically after merging a feature branch into main.
The standard command: