Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to delete multiple local branches at once?

farmerpaul November 8, 2012

We use the git flow branching model, and I'm happy to see support for it in SourceTree and I make good use of it there. In this branching model, I find myself accumulating many feature branches (one corresponding to each of our JIRA issues), and after completing the feature I usually issue a pull request to have it merged into our main "develop" branch. However, what happens is I end up accumulating lots of feature branches that eventually have to all be deleted once they've been merged.

Is there a way to select several branches at once and ask SourceTree to delete all of them in one go? Ideally, it would delete all the ones for which git issued no warnings and skip those which produced warnings (because I don't want to accidentally delete any branches that haven't yet been merged).

2 answers

1 accepted

42 votes
Answer accepted
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 8, 2012

Actually there is a bulk delete branch option, it's just not that obvious :/

If you click the 'Branch' button, there's an extra tab labelled 'Delete Branches' where you can check the ones you want to delete (local or remote) and delete them all at once.

farmerpaul November 8, 2012

Sweet, thanks for pointing that out, Steve. Now... if only I could click one item, hold shift, then another item to select the range of branches, that would be awesome. :)

Like Edward Keenan likes this
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 8, 2012

Argh, so close! ;)

Vishwajeet Singh
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 8, 2012

That makes feel so dumb :-p

passsy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 10, 2015

Thanks! But why is multiselect in the branch list not possible?

Like Julix likes this
Murali Prashanth
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 15, 2016

Awesome

 

BlueRaja April 4, 2016

There's no shift+click to select multiple lines?  And there's no hitting space to check the checkbox?  You have to manually click the checkbox on every line!?

This dialog is practically unusable, does anyone on the Sourcetree team actually use it?

Like Julix likes this
Jared Schraub
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 12, 2016

I never realized that was hiding in plain sight.  Thanks for the help.

Samantha Donga
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 4, 2017

Thanks for your help.

Toby Beresford
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 22, 2017

+1 @BlueRaja comment. I've just had to click 250 something times to delete all my local branches and remote branches.  I'd have thought this sort of bulk housekeeping is exactly the use case for something like SourceTree. Can't you turn it into a clicking game like Farmville! Or better still add a filter / select all...

Like Julix likes this
Dav Yaginuma
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 15, 2018

I've spent years deleting branches one at a time cursing under my breath at the lousy UX. It's still a lousy UX (it should really just be supported to select multiple in the browser pane) but I'm glad to see it wasn't a complete product feature oversight.

Jim
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 8, 2024

As of mid-January 2024, this no longer works. The checkboxes do not allow for more than one branch to be selected - they behave not like checkboxes but radio buttons. Hopefully Atlassian sees this as a bug and fixes it immediately

Taylor Plimpton
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 2, 2024

Shift clicking multiple branches works for me.

0 votes
Vishwajeet Singh
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 8, 2012

AFAIK it's not possible to delete multiple branches in sourcetree, you would need to resort to git commandline for the same you can use git for-each-ref

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events