Reputation: 12391
When I give a command: git branch
it shows me the following:
HSM2-585
* POLTODO-111
POLTODO-283
develop
master
But when in console I press the TAB
key it lists me the following:
I am using ubuntu 16.04.
develop HSM2-585 origin/develop origin/master origin/#TODO-269
FETCH_HEAD master origin/HEAD origin/#TODO-111 origin/TODO-283 TODO-111
HEAD ORIG_HEAD origin/HSM2-585 origin/TODO-111 origin/TODO-286 TODO-283
So old branches what I've already deleted from local and remote too appears.
The funniest that I could checkout the origin/TODO-286
for example. I am using Gitlab.
How do I purge these old and deleted branches?
Upvotes: 0
Views: 650
Reputation: 4164
As @LasseVågsætherKarlsen said in a comment, you need to use git fetch --prune
. What you're seeing is remote-tracking branches, these are in the format <remote>/<branch-name>
such as origin/TODO-111
.
The documentation for git fetch
with the -p or --prune
flag says:
Before fetching, remove any remote-tracking references that no longer exist on the remote.
So using this will clear out those old and unwanted tracking branches. git branch --all
should then be clean of these branches. As will git branch [TAB]
Upvotes: 3