How to delete a local branch in git

You can delete any local branch on GitHub.

Delete the branch by typing:

git branch -d <branch_name>

branch_name is the name of the branch you want to delete.

Note: Use -d if the branch has already been pushed and merged with the remote branch. Else, use -D.

If you want to delete the current branch, be sure to checkout to another branch by typing:

git checkout master

Then, delete the branch using:

git branch -d <branch_name> 

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved