Use any of the commands below to delete the Local Git Branch that best suits your needs. To remove local git branch follow one of the below commands.
git branch -D <name_of_branch>
git branch -d <name_of_branch>
Here -D
and -d
works as explained below :
- The
-D
flag in the above code is an alias for--delete --force
, which helps to delete the branch regardless of its merged status. - The
-d
option in the above code is an alias for--delete
, which deletes the branch only if the branch has been fully merged in it’s upstream previously. - If you try to attempt to delete the present chosen branch, you will caught up with an error.
Also Read:
How to Delete Remote Git Branch