You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi!
I've deleted a branch in my remote repository, but sourcetree keeps showing it in the list of local branches. Is there any way Sourcetree automatically remove the local branch if it was already deleted in the remote repository?
Thanks
You need to do a Fetch and check the box to prune tracking branches, that will remove branches that you have removed on the remote.
This will only remove Branches under "Remote" and not my "Local" Checked out (now remotely deleted) Branches, yes?
If so: How I can "Prune" my Local branches?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Johannes Sebastian Correct, the fetch will only affect remote branches. To delete local branches you have to right-click on it and select Delete... Note that you can only delete branches that are not checked out.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for a quick response.
That is the answer I was expecting. Remote actions will not affect my local branches.
I am sure there is are good arguments for this....
However, that is what I need.
It is a small feature and I hope SourceTree will offer it in the future :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Might I add, because I just spent about 15 minutes trying to figure out why I don't see a checkbox about pruning. If you are right clicking with the mouse in the left panel under remotes on the origin itself to perform the fetch operation, the popup for additional checkboxes does not appear. If you click the fetch button at the top menu of the app, then you do see the popup of additional checkboxes. So not a bug, just a useability thing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This cannot be done automatically from within SourceTree UI but you can run the following command on git cmd:
git branch -vv | grep ': gone]' | grep -v "\*" | awk '{ print $1; }' | xargs -r git branch -D
You can create your own alias too:
git config --global alias.delete-gone-branches "! git branch -vv | grep ': gone]' | grep -v \"*\" | awk '{ print \$1; }' | xargs -r git branch -D"
And then run it git delete-gone-branches
.
Sources:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mac, bitbucket
open my project and open terminal
run
git branch -vv | grep ': gone]' | grep -v "\*" | awk '{ print $1; }' | xargs -r git branch -D
the branches are still on remote when using source tree
they are not there when looking on the web
close and open source tree
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My answer deletes LOCAL branches that are no longer present on remote.
You're referring to REMOTE branches in your local SourceTree - that's different.
To delete these remote branches from your SourceTree you have to fetch remote repo with "Prune tracking branches no longer present on remote(s)".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As @Mikael Sandberg mentioned, you can use "Fetch" and tick "Prune tracking branches no longer present on remotes" to sync remote branches.
For local branches, even though there is no automatic way, there is a way quicker than clicking through all unwanted branches.
Just click "Branch"
then select "Delete Branches"
then tick all unwanted local branches
and select delete branches
Voila, done.
Please note you can also delete remote branches here, even force delete them -- just be careful :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.