Deleting a local git branch

clean up the branch list with this one-liner command-line command
// updated 2025-04-24 17:05

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!)

newer (in toolshed) ➡️
TypeScript overview 🟦
⬅️ older (in code)
🐙 Git command aliasing
newer (in code) ➡️
TypeScript overview 🟦
⬅️ older (posts)
🐙 Git command aliasing
newer (posts) ➡️
Samizdat 📜