Baldráni Baldráni - 1 month ago 12
Git Question

Git pull create a new branch every time

So I have a strange bug with git.

Every time and wherever I launch a

git pull
I'm ending up with a new branch created.

* [new branch] Lazy-loading -> origin/Lazy-loading


However this branch is since a long time merge on the master and has not been updated since ages.

Could it be due to some cache problem somewhere? How can I clean this?

Answer

Whenever you do git pull, git fetches all branches that exist remotely and updates remote references for them.

* ef84e7e..6ee10e3  master     -> origin/master
* [new branch]      Lazy-loading -> origin/Lazy-loading

[new branch] means that there was branch called Lazy-loading in remote repository, but not in your local repository.

You should delete that branch remotely first with git push origin --delete Lazy-loading or git push origin :Lazy-loading to stop this happening.

Then you could do this:

git fetch --prune

This will fetch from remote repository again and delete all local branches which track branches that no longer exist on the remote.

--prune

Before fetching, remove any remote-tracking references that no longer exist on the remote. Tags are not subject to pruning if they are fetched only because of the default tag auto-following or due to a --tags option. However, if tags are fetched due to an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the --mirror option), then they are also subject to pruning.

Comments