Deleting a local git branch

clean up the branch list with this one-liner command-line command

notes2023-12-10 03:24

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

1$ 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:

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

(Note the capital D!)