Deleting a Branch

Learn how to delete a branch from your local repository in this lesson.

Using git branch to delete a branch

We can use the git branch command to create, list, rename, and delete a branch. In this lesson, we will take a look at how we can delete a branch from our repository.

The -d flag

The syntax for deleting a branch is fairly simple:

git branch -d <branch_name>

If you have a branch called new_branch in your repository and want to remove it, you will need to enter the following command in the terminal:

git branch -d new_branch

Get hands-on with 1200+ tech skills courses.