Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Podia.

Delete a branch – Git

Summary

To delete a branch in Git, enter the following command in your terminal:

git branch -d branch-name

Details

Before you run the above command, make sure you’re on a different branch than the one you’re trying to delete. You can switch branches by entering the following command in your terminal:

git checkout other-branch

After running the delete command, you should see something similar to the following output:

Deleted branch branch-name (was 1f0de91).

Exercises

Use the following command to delete the dev-branch:

git branch -d dev-branch

References

Basic Branching and Merging from the Pro Git book

Back to: Git Reference > Git Intermediate