How to Delete a Branch in GitHub: Local, Remote, and Everything In Between

Branches are one of GitHub's most useful features — they let you experiment, build features, and fix bugs without touching your main codebase. But once a branch has served its purpose, leaving it around creates clutter. Knowing how to delete branches cleanly, and understanding which deletion method applies to your situation, is a core part of working with Git effectively.

What Happens When You Delete a Branch

Deleting a branch in Git doesn't delete the commits that branch contains — as long as those commits were merged into another branch before deletion. What you're removing is the pointer (the branch reference) that tracked that line of work.

This distinction matters. A merged branch can be safely deleted without losing any history. An unmerged branch, however, contains commits that exist nowhere else. Deleting it means losing that work unless you explicitly force the deletion knowing what you're doing.

There are also two separate locations a branch can live:

  • Local — on your own machine, in your Git repository
  • Remote — on GitHub's servers, visible to your whole team

These are independent. Deleting one does not automatically delete the other.

Deleting a Branch on GitHub (Remote) via the Web Interface 🖥️

The simplest method requires no command line at all.

  1. Go to your repository on github.com
  2. Click the "branches" link near the top of the file list (it shows the branch count)
  3. Find the branch you want to remove
  4. Click the trash icon next to it

GitHub also prompts you to delete a branch immediately after a pull request is merged. That prompt appears right on the pull request page and is the most common way teams clean up branches during normal workflow.

If you delete a branch by accident through the web interface, GitHub offers a "Restore branch" button for a short period after deletion — useful safety net if you move too fast.

Deleting a Remote Branch via the Command Line

If you prefer the terminal or are working in an automated script, the command is: