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 - Remove Branch

Hi All

I am working my way through the GIT course at the moment and need to delete a branch in origin - can someone tell me the best way to do this please.

G

6 Answers

Chris McKnight
Chris McKnight
11,045 Points

To delete a branch on the remote origin run git push origin :remote_branch_to_delete. The colon in front of the remote says to remove the remote branch. You can also use the more explicit git push origin --delete remote_branch_to_delete

Boom! (at the bottom) http://git-scm.com/book/ch3-5.html

Cool John W much appreciated I went with

git branch -d the_local_branch

in the end

Dean Phillips
Dean Phillips
22,260 Points

I can't get the challenge to remove the branch another_new_feature to work. I'm trying "git branch -d another_new_feature"

Chris McKnight
Chris McKnight
11,045 Points

That deletes the local branch. Are you trying to delete the local branch or the remote branch? See my answer for how to delete a remote branch

Dean Phillips
Dean Phillips
22,260 Points

Local. When I try the push command as if it was a remote it says wrong command.

Chris McKnight
Chris McKnight
11,045 Points

git branch -d or git branch -D will do it unless it's a bug. git branch -D will force delete the branch meaning delete the branch even if it hasn't been merged

Dean Phillips
Dean Phillips
22,260 Points

Thanks Chris...It was the capital D.