Deleting a local git branch

clean up the branch list with this one-liner command-line command
// updated 2025-04-25 16:01

To delete a local git branch, use the following command:

$ git branch -d <local-branch-name>

This will fail if you have not:

  • merged this branch's code into other branches
  • pushed this code to a remote repository

To delete the branch without doing all of that, we have an alternate command:

$ git branch -D <local-branch-name>

(Note the capital D!)

⬅️ older (in textbook-git)
🐙 Git and GitHub configuration
newer (in textbook-git) ➡️
Git command aliasing 🐙
⬅️ older (in code)
🐙 Git and GitHub configuration
newer (in code) ➡️
Git command aliasing 🐙
⬅️ older (posts)
🐙 Git and GitHub configuration
newer (posts) ➡️
Git command aliasing 🐙