Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I remote prune origin in SourceTree?

Using the command line, I can

git remote prune origin

to bring the list of remote branches up to date with the remote. I cannot find any way to do this in SourceTree. The branches have already been deleted from BitBucket by another user of the repo, but I have the legacy refs on my local repository.

If I right click on each one I can delete it (thought it warns that it will be deleting it from the remote) and that's not what I'm looking for, though it may achieve the same result in the end ...

5 answers

1 accepted

30 votes
Answer accepted

You should be able to achieve this by using the 'Fetch' button on the toolbar and checking the 'Prune tracking branches no longer on the remote(s)' option.

Perfect! Thank you. The option dialog isn't there when you use the right click 'Fetch from origin', only when you use the top menu option.

Thanks, Dana--wouldn't have known that if you hadn't mentioned it.

Why the heck is this not automatic; if it's gone from original ST should show it as gone from origin? Is there any use-case where this is not the desired behavior?

Like # people like this

This app is missing a lot of user centric design. I always have to do all the mindless steps, just because there might be a weird edge case for someone who might not want to have it.

Like Raj Parmar likes this

I'm using Version 1.8.1 (1.8.1) in MacOSX and this doesn't work. The local stale tracking branches are not removed.

Is this a known issue?

0 votes
Deleted user Mar 11, 2014

Hi Vincenzo, You're not alone, have the same problem here (using Gitlab). Here's another topic with the same problem.

Hi guys, this still seems to be an issue a year later. Fetch does not prune removed remotes, this seems like a bug. Is there a corresponding issue in the Atlassian Jira?

Works on Mac (OS X Yosemite 10.10.3) and SourceTree (2.0.5.2) through the top level menu (Repository -> Fetch).

Hi Guys its 2 years or so and I still can't prune local branches which have been merged and deleted from Master

Reza, it sounds like you might want something different. Are you hoping to have actual local branches removed, or do you just mean that you're seeing remote branches that should be deleted? I wouldn't expect anything to happen to local branches unless you explicitly tried to delete them. 

Hi Graham,

I want the branches that have been merged into Master to be removed locally. Currently I have to figure out which ones were merged and delete them manually. 

I don't think it's likely that you'd ever see SourceTree work that way, as it's contrary to how Git itself is intended to work. Your local copy is intended to be exactly that -- local, unaffected by remote changes. You shouldn't have local copies of branches unless you specifically check them out, though, so you wouldn't need to delete anything that you hadn't interacted with.

You could potentially write some sort of script to delete local branches that don't have remote counterparts, but this seems like it'd be extremely dangerous and cause things like accidentally deleting local work that you hadn't yet pushed. Something less invasive might just be a script to identify which branches don't have remotes, and you could actually do that via SourceTree by clicking push -- this brings up a little window showing which remotes to push to, it should be apparent which ones are missing remotes and are therefore deletable (shown below).

no-remote.PNG
I would advocate hugely against SourceTree doing anything to manipulate local branches based on remote status, though. That would only cause more trouble.

Still a bug - would be nice if the client could do the same as `git remote prune origin` does on the CLI.

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

777 views 15 10
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you