Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is git pull showing new branches all the time?

Tags:

git

I'm using git bash for Windows:

$ git version git version 1.8.0.msysgit.0 

Everything has been working fine for months, I've been gradually getting used to how git works, then all of a sudden, git pull is retrieving a number of "new" branches each time I try to pull:

me@MYPC /d/Projects/MyProject (master) $ git pull From github.com:ClientUsername/RepoName  * [new branch]      branch1 -> origin/branch1  * [new branch]      branch2 -> origin/branch2 Already up-to-date.  me@MYPC /d/Projects/MyProject (master) $ git pull From github.com:ClientUsername/RepoName  * [new branch]      branch1 -> origin/branch1  * [new branch]      branch2 -> origin/branch2 Already up-to-date. 

Have I configured something incorrectly? Is this normal behavior?


EDIT

After some helpful comments, I deleted the branch files from .git\refs\remotes\origin. I tried to pull again and got the following:

me@MyPC /d/Projects/MyProject (master) $ git pull From github.com:ClientUsername/RepoName  * [new branch]      Branch1 -> origin/Branch1  * [new branch]      Branch2 -> origin/Branch2  * [new branch]      branch1 -> origin/branch1  * [new branch]      branch2 -> origin/branch2 Already up-to-date. me@MyPC /d/Projects/MyProject (master) $ git pull From github.com:ClientUsername/RepoName  * [new branch]      Branch1 -> origin/Branch1  * [new branch]      Branch2 -> origin/Branch2 Already up-to-date. 

The only difference being the case of the branch names?

like image 523
Spikeh Avatar asked Jul 02 '13 10:07

Spikeh


People also ask

Does git pull get new branches?

Also, git pull --all will update your local tracking branches, but depending on your local commits and how the 'merge' configure option is set it might create a merge commit, fast-forward or fail.

Does a git pull update all branches?

No. git-pull will only ever incorporate changes to your local branch. If you want the updates for each other branch, you'll have to check them out and pull down their updates individually.

Why my git pull is not working?

This might be happening because of some conflict files present in your repository . And you was still trying to check in files . So After that what happen , it will check in your local repository not in master repository . So u was not able to pull or check in anythings in master(head) repository .


2 Answers

In my case, the issue was related to two branches having the same name (one uppercase, one lower case). Once I removed the "duplicate" branch from remote origin, I ran the following:

git fetch --prune origin 

and the [new branch] message stop showing after every pull. For documentation on prune see reference.

like image 140
Alberto Guerrero Avatar answered Oct 17 '22 07:10

Alberto Guerrero


I could reproduce the behavior by having a branch not listed in .git/packed_refs and renaming its file in .git/refs/remotes/origin to the same but different case. (on NTFS filesystem). And it is cured by renaming back.

Guess if you could rename to the form that matches the remote name, it would be a fix for you.

Thinking more, and using the first form after edit:

You must have two branches with similar name just differing in case on remote!

And the problem is because they want to create the same file. You must fix it on the remote, by renaming one of the similar-named branches.

like image 20
Balog Pal Avatar answered Oct 17 '22 07:10

Balog Pal