Why do I see a remote remote branch?

I have a remote repository and 2 clones.
I create a branch in one of the clones, for example. test . I am doing some work and 2 commits. I join the master branch and push -u to the branch.
I am doing git pull in another clone.
I see both master and test .
In the first clone project, I do:
git origin :test to remove the test branch in the remote repository.
test is deleted on remote repositories.
I am doing git branch -D test and the test branch is also deleted locally.
If I do git branch -a , I get:

 *master remotes/origin/master 

Now in the second repository I am doing git pull .
On pulling out, the local test seems remote, but git seems to β€œthink” that the remote test branch still exists.
If I do git branch -a , I get:

 * master remotes/origin/HEAD -> origin/master remotes/origin/master remotes/origin/test 

Why is the remote test branch displayed as the remote branch?

+8
source share
2 answers

The default options for git fetch (and therefore git pull ) do not crop remote branches. I am not sure what the logic of this default is. In either case, to trim the deleted remote branches, either select with

 git fetch -p 

or run

 git remote prune [-n] <name> 

explicitly. With the -n flag, he will tell which branches will be trimmed, but not really trim them. See git -fetch (1) and git -remote (1) for more information.

+13
source

Try using this command git remote prune origin . The remote branch should disappear. This should remove local links to remote branches.

+3
source

All Articles