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 ...
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.
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).
I would advocate hugely against SourceTree doing anything to manipulate local branches based on remote status, though. That would only cause more trouble.
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...
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!
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