From: Jakub Narebski Date: Thu, 02 Jun 2011 20:02:31 GMT Subject: Re: git clone (ssh://) skips detached HEAD Message-ID: <201106022202.33393.jnareb@gmail.com> In-Reply-To: <20110601225128.GB16820@sigill.intra.peff.net> On Thu, 2 Jun 2011, Jeff King wrote: > On Wed, Jun 01, 2011 at 03:42:58PM -0700, Jakub Narebski wrote: > > > > The reason is that the default refspec on clone is: > > > > > > $ git config remote.origin.fetch > > > +refs/heads/*:refs/remotes/origin/* > > > > > > And HEAD is not under refs/heads/. > > > > Hmmm... HEAD is a bit of special case, as HEAD should really land in > > refs/remotes/origin/HEAD from what I understand. > > No, that is always supposed to be a symbolic ref. Making it a real ref > would be confusing. I don't think fetch should look at HEAD at all; it's > outside its refspec. However, clone does treat HEAD specially, and > should probably convert the remote's detached HEAD into a local detached > HEAD (we already do if it's part of referenced history). Hmmm... in ordinary case (not on detached HEAD) "git fetch" would never modify my local branches nor my local HEAD. On the other hand IIRC origin/HEAD do not follow switching branches at origin, and is staying at the value at clone (or "git remote set-head"), isn't it? So what to do when HEAD on origin is detached? Modify .git/HEAD, or maybe .git/refs/remotes/origin/HEAD? -- Jakub Narebski Poland