How to delete multiple local branches at once?

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

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.

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. :)

That makes feel so dumb :-p

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

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?

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

Thanks for your help.

+1 @Blue Raja 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...

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 Join to answer
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

234 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot