How to Delete a Local Git Branch?

Find out how to remove a local git branch

The command to delete a local git branch has the following syntax:

git branch --delete <branch_name>

# or the shorter version
git branch -d <branch_name>

You can also force-delete a branch using the -D flag like so:

git branch -D <branch_name>

For example, to remove the local branch called "foo" you could use any of the following commands:

git branch --delete foo

# or the shorter version
git branch -d foo

# force-delete
git branch -D foo

Please note that these commands do not delete the remote branch. Deleting a remote branch is done in an entirely different way.

Hope you found this post useful. It was published . Please show your love and support by sharing this post.