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

remote branches are not removed from the list after being deleted

Khaled Ayoubi August 23, 2012

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

79 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.
August 24, 2012

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.

Alexey Strelkov April 26, 2015

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)

jaessi June 16, 2017

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.

Crystal O'Mara September 27, 2017

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
Sebastian Wolf November 30, 2017

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!

mhanslo March 26, 2018

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
Eric April 26, 2019

That did not work for me.

Like Ravi Pandey likes this
Nicklas Frederiksen January 20, 2020

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
bastula July 31, 2020

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!

Like Jonathon Broughton likes this
3 votes
onefivefour November 4, 2018

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

Irina Shanina January 23, 2019

Thanks. It works. 

Chip Broecker April 26, 2019

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.

Dado Sorsano February 4, 2020

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'. 

2 votes
Cyprian Kowalczyk July 5, 2013

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

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.
July 7, 2013

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
1 vote
Chris Chan June 7, 2019

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!

suneel G December 1, 2019

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

Like Paul Kern likes this
tbroniewski January 20, 2020

"git fetch -p origin" worked for me!

Like suneel G likes this
0 votes
Aman Bains May 26, 2019

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.

0 votes
Cyprian Kowalczyk July 7, 2013

Thanks for explanation!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events