# git fetch specific ref fails when run against a remote where HEAD points to missing master branch

1 messages from 2014-09-17 to 2014-09-17. Participants: Keller, Jacob E.
Thread: https://gitlist.dev/t/37584

## Keller, Jacob E, 2014-09-17 17:40

Subject: git fetch specific ref fails when run against a remote where HEAD points to missing master branch
Message-ID: <1410975603.23945.4.camel@jekeller-desk1.amr.corp.intel.com>
URL: https://gitlist.dev/e/1410975603.23945.4.camel%40jekeller-desk1.amr.corp.intel.com

```
Hi,

I am assuming this is simply a configuration issue on my end for this
particular remote, because I never pushed to the master branch, and so
the HEAD of this remote doesn't exist.

However, I am also using it to fetch specific refs I know the name of,
so it confuses me when I try to fetch and get back a failure, because
the remote HEAD ref doesn't exist...

Command "git fetch --tags --progress git://gitlad.jf.intel.com/git/jekeller/testing/ixgbe +refs/heads/*:refs/remotes/origin/*" returned status code 1:
stdout: Fetching submodule src/COMPAT

stderr: remote: Counting objects: 9, done.        
remote: Compressing objects:  33% (1/3)           
remote: Compressing objects:  66% (2/3)           
remote: Compressing objects: 100% (3/3)           
remote: Compressing objects: 100% (3/3), done.        
remote: Total 3 (delta 1), reused 0 (delta 0)        
From git://gitlad.jf.intel.com/git/jekeller/testing/ixgbe
 * [new branch]      2014-09-17-b6c6ff2c76ae -> origin/2014-09-17-b6c6ff2c76ae
fatal: Couldn't find remote ref HEAD

So in order to understand what I am doing:

I have a continuous integration build, which I can pre-test a series of
commits before pushing it to the real remote, by pushing to a ref in
this repository, and then indicating to my continuous build server to
test against that ref.

As it turns out, my remote didn't have a master branch, (as I never
pushed anything there!), and so even though it was a bare repository,
HEAD was pointing still to refs/heads/master

I fixed this issue by adding a master branch that was empty. I also
assume I could have updated HEAD to point to a different location if I
wanted also.. but I'm not sure this should be an error in the case that
I fetch a specific ref by command line parameter? Especially as it
manages to fetch all the refs I asked for correctly, but still fails
with a non-zero exit value.

Regards,
Jake

```
