Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Git Basics Branches Managing Our Branches

Denise Edwards
Denise Edwards
4,924 Points

Do you really need the capital D to delete a branch?

"git branch -d [branch_name]" seems to work the same? Is there a difference between using "-D" and "-d"?

2 Answers

Yes, there's a difference. The capital D is like a "force" version of -d. If the branch isn't fully merged you'll get an error if you use the lowercase version.

Uppercase and lowercase flags like this are common in git, and share the similar differences.

Denise Edwards
Denise Edwards
4,924 Points

I see! If that's the case though, wouldn't it be a better idea to use the lowercase whenever possible? That way there's less of a chance of screwing things up if you didn't fully merge, like you said. Why is it better to use the capital (or why do you think Tommy choose to teach it that way?)

Well one less warning to worry about I suppose :)

I think the lesson taught us -D rather than -d because we didn't learn merging yet at this point in the course.

from this Medium post

The -d option stands for --delete, which would delete the local branch, only if you have already pushed and merged it with your remote branches.

The -D option stands for --delete --force, which deletes the branch regardless of its push and merge status, so be careful using this one!