Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git fetch repeatedly tells me about the same new branch

Tags:

git

On one particular repo, when I run

git fetch

It does all the stuff it's supposed to do, but also reports:

 * [new branch]      Story/abc-123 -> origin/Story/abc-123

every single time.

if I run git branch -r | grep abc-123, it yields:

origin/story/abc-123

Note that in the output from the fetch, 'Story' is capitalized, but in the branch -r output it is not. The problem seems to be local. I don't have this issue if I make a new clone of the repo elsewhere, but I'd rather not go down this road if I can avoid it.

Is there any way to make it stop doing this?

like image 724
Some Guy Avatar asked Dec 08 '14 22:12

Some Guy


People also ask

Does git fetch get new branches?

fetch will not update local branches (which track remote branches); if you want to update your local branches you still need to pull every branch. fetch will not create local branches (which track remote branches), you have to do this manually.

Does git fetch change anything?

git fetch is the command that tells your local git to retrieve the latest meta-data info from the original (yet doesn't do any file transferring. It's more like just checking to see if there are any changes available). git pull on the other hand does that AND brings (copy) those changes from the remote repository.

Does git fetch update all branches?

On its own, git fetch updates all the remote tracking branches in local repository. No changes are actually reflected on any of the local working branches.

How often should you git fetch?

git pull is one of the 4 remote operations within Git. Without running git pull , your local repository will never be updated with changes from the remote. git pull should be used every day you interact with a repository with a remote, at the minimum.


1 Answers

The problem here is that your ./git/refs directory is in a different case for part of the branch name compared to the actual remote. I.e., git branch thinks the branch is lower case:

$git branch 
...
origin/story/abc-123
... 

But your copy of the refs thinks the story directory is upper case:

$ls .git/refs/remotes/origin
...
Story
...

Apparently you can just delete the entire refs directory and git will regenerate it, but because I was a coward I just fixed it by renaming the offending directory:

mv .git/refs/remotes/origin/Story .git/refs/remotes/origin/story
like image 123
Jeffrey Theobald Avatar answered Oct 06 '22 13:10

Jeffrey Theobald