On Tue, Nov 17, 2020 at 7:22 PM Jeff King <peff@xxxxxxxx> wrote: > > On Tue, Nov 17, 2020 at 06:18:03PM -0600, Felipe Contreras wrote: > > > On Tue, Nov 17, 2020 at 5:33 PM Jeff King <peff@xxxxxxxx> wrote: > > > On Tue, Nov 17, 2020 at 04:47:56PM -0600, Felipe Contreras wrote: > > > > > > This should be easy to do if we make "origin" be a pseudo ref that > > > > points to "origin/HEAD" (and we could introduce "origin/@"). > > > > > > Didn't we already do this long ago? refs/remotes/%s/HEAD is special in > > > the dwim_ref() lookup: > > > > > > $ git rev-parse --symbolic-full-name origin > > > refs/remotes/origin/master > > > > Hmmm. For some reason none of my remotes do have a HEAD. > > > > If I do "git remote add", and then fetch, the HEAD doesn't seem to be present. > > Yes, I have run into that, and it's definitely annoying. The > refs/remotes/<remote>/HEAD symref is created by clone, but is not > updated by "fetch". That's intentional, because it's supposed to > represent a local choice (that is merely seeded by the remote side). But > it seems like adding it if it's missing might be reasonable. The equivalent of this choice is in "git remote add -m": With `-m <master>` option, a symbolic-ref `refs/remotes/<name>/HEAD` is set up to point at remote's `<master>` branch. See also the set-head command. This is of course inconsistent. Is it the "head", or is it the "master"? Presumably if we want to avoid the term "master", then this option needs to be renamed. In my opinion unless this option has been explicitly set, "origin/HEAD" should keep track of whatever remote head is set. If somebody updates its remote HEAD from "master" to "main", then origin/HEAD should be updated accordingly. Granted, this may be some overhead in the 99.999% of the cases where the remote HEAD is the same, so it may not be worth even thinking about it. But at least the first fetch after "git remote add" should fetch it, in my opinion (unless it's manually configured already). I'm not sure if origin/HEAD can contain some placeholder so that "git fetch" knows what to do. Cheers. -- Felipe Contreras