0

TL;DR
How can I tell Git to completely ignore remote branches that I don't care about?

Details

I am working in a very large project hosted in an internal Git repository. On one of my local clones, my master branch is tracking the remote master on origin. For this particular clone, I don't care about anything besides master. However, when I issue git pull, I sometimes see:

error: cannot lock ref 
'refs/remotes/origin/<branch>': is at <hash> but expected <other hash>  

Where <branch> is some random person's development branch that I don't care about, and my master branch ends up not getting completely updated. I have successfully used git gc --prune=now and git remote prune origin as suggested in this SO answer, but it has happened multiple times now, and I don't want to keep fixing it manually. I can also use git pull origin master:master, but I'd prefer to just use git pull.

I don't care about this branch and never will. I've never checked out anything besides master in this clone, and am not tracking anything else:

m:\<path>\> git branch
* master

How can I tell git to stop doing whatever tracking information it's doing in the background when I just want to pull master?

Additional Note
Our team's move to Git is very recent, and we're still working out kinks in our workflow. I don't know if the other developer is doing something weird or not, but I don't really care - I want to know how I can tell Git, "No matter what happens to the other branches, just pull the one I ask when I say pull."

Community
  • 1
  • 1
skrrgwasme
  • 9,358
  • 11
  • 54
  • 84

1 Answers1

2

Tell git to only fetch master branch instead of all branches:

git config remote.origin.fetch +refs/heads/master:refs/remotes/origin/master
Vampire
  • 35,631
  • 4
  • 76
  • 102