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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

remote branches are not removed from the list after being deleted

I have few remote repositories configured for my project, whenever a new branch created it shows up under the remore repository, but when they are deleted later on, they are not removed from the list and there is no way to remove them unless I remove the remote repository and add it again

6 answers

1 accepted

76 votes
Answer accepted

This is because git always keeps a local record of the remote branch.

To remove these local records, use the Fetch toolbar button and check the 'Prune' option.

That didn't do it. The branches are still there in the sidebar in the "remotes" section under my origin :( This list clutters very fast (though these branches are not present in bitbucket web list of branches)

You can remove those branch labels that no longer exist on your remote by expanding your Remotes in the sidebar and right-click the branch name and choose delete.

I am having the same issue. I selected "Fetch" then "Fetch from all remotes" and "Prune tracking branches...". Reloaded SourceTree and they were still there. I then tried to right click and "Force Delete" them but I get an error saying they no longer exist... I tried restarting SourceTree after that too and no luck :(

Like Autumrose Stubbs likes this

Same here as @Crystal O'Mara, it never removes them after sync and prune. If you're using feature branches, then tens/hundreds of branches fill the list and it is unusable!

If anyone is still having issues with dangling remote branches following a fetch and prune, try deleting your project and then cloning it down again. Sourcetree then correctly located my branches in a different sub-folder (which was capitalized) and succeeded in deleting them permanently.

Like # people like this

That did not work for me.

Like Ravi Pandey likes this

I had this problem too.

I unchecked the prune checkbox in Fetch and clicked ok. Then checked the prune checkbox again and fetched. Origin was then cleared for non-existing branches.

Like # people like this

This worked great! I was doing this manually for so long until I got tired of it and found this question and answer. Thank you!

What can be the reason when local branch is not pruned after fetching?

Local branches are never removed by 'git fetch --prune'. Fetch only affects remote branches (i.e. your local record of what the remote branches are).

Like Will Cobbett likes this

I solved this by deleting the "origin" folder in .git/refs/remotes/

Thanks. It works. 

In windows 10. it seems to come back like a birthday candle.  I deleted c:\users\xx\Projects\yyyy\.git\refs\remotes\origin and c:\users\xx\Projects\yyyy\.git\rogs\refs\remotes\origin  .  Then sourcetree managed to conjure up the old branches from somewhere.  they dont show in Bitbucket web UI.

You will need to delete the local branches manually (i.e. right click branch and delete). Should there be un-pushed commits locally, you will have to tick 'Force Delete'. 

Remove deleted branches always seem to stick around no matter what in Windows even if running `git fetch -p origin` removes them.  However this powershell command has always worked for me to remove all merged branches:


git branch --merged | ? {$_[0] -ne '*'} | % {$_.trim()} | % {git branch -d $_}


It's a lot easier than manually deleting them in sourcetree all the time!

This worked, "git fetch -p origin" cleaned the remote branches in the local projects. 

Like Paul Kern likes this

"git fetch -p origin" worked for me!

Like suneel G likes this

Thanks for explanation!

You need to delete the local branches manually. when you run "git fetch -- prune" . the list of deleted remote branches will appear.


Then you need to manually delete all local branches with the same names by right clicking and selecting delete on all such branches.

keep doing it twice a week and it will not be difficult.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in DevOps

Step up your DevOps game webinar Q&A series - Questions answered!

  On October 21st, 2020 we hosted a webinar titled,   Step Up You DevOps Game with 4 Key Integrations for Jira and Bitbucket. We had a great showing and high engagement, but that meant th...

101 views 0 1
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