# Fetch and refs/remotes/<refname>/HEAD

2 messages from 2015-08-03 to 2015-08-09. Participants: Dror Livne, Jeff King.
Thread: https://gitlist.dev/t/39999

## Dror Livne, 2015-08-03 13:28

Subject: Fetch and refs/remotes/<refname>/HEAD
Message-ID: <loom.20150803T151815-131@post.gmane.org>
URL: https://gitlist.dev/e/loom.20150803T151815-131%40post.gmane.org

```
I have noticed that when cloning a repository, I get a
refs/remotes/origin/HEAD symbolic ref.

On the other hand, when fetching a new remote, the remote HEAD is not set by
git-fetch (but can be added later by `git remote set-head ...')

I was under the impression that clone is equivalent to (at least) init+fetch.

Is there a rationale for that difference in behavior?

Dror Livne

```

## Jeff King, 2015-08-09 23:23

Subject: Re: Fetch and refs/remotes/<refname>/HEAD
Message-ID: <20150809232330.GA25769@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20150809232330.GA25769%40sigill.intra.peff.net
In-Reply-To: <loom.20150803T151815-131@post.gmane.org>

```
On Mon, Aug 03, 2015 at 01:28:05PM +0000, Dror Livne wrote:

> I have noticed that when cloning a repository, I get a
> refs/remotes/origin/HEAD symbolic ref.
> 
> On the other hand, when fetching a new remote, the remote HEAD is not set by
> git-fetch (but can be added later by `git remote set-head ...')
> 
> I was under the impression that clone is equivalent to (at least) init+fetch.
> 
> Is there a rationale for that difference in behavior?

I have been annoyed by this in the past, too. There's no real reason,
except that setting up the symref is outside the scope of "fetch".
Fetching is just about updating refs, and we explicitly do not want
subsequent fetches to overwrite any changes you might make to
refs/remotes/.../HEAD.

Setting up the remote HEAD symref more rightly belongs to "git remote
add", but that program does not otherwise talk to the remote. And that's
why we end up with the separate set-head step.  It might make sense for
"git remote add -f" to automatically run "set-head", since it is
contacting the remote server already. And then:

  git init
  git remote add -f origin ...

would be similar to "git clone".

-Peff

```
