Baldráni
Baldráni

Reputation: 5640

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?

Upvotes: 1

Views: 1600

Answers (2)

user7018603
user7018603

Reputation:

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.

Upvotes: 4

Pan Long
Pan Long

Reputation: 1032

If you are not going to use the branch at all, you can delete it both locally and remotely:

To delete the local branch:

git branch -d Lazy-loading

Then delete it remotely:

git push origin --delete Lazy-loading

Upvotes: -1

Related Questions