Thread (6 messages) 6 messages, 4 authors, 2024-08-20

Re: feature request: set remote/HEAD with fetch

From: Jeff King <hidden>
Date: 2024-08-17 05:09:55

On Fri, Aug 16, 2024 at 09:55:00PM +0000, brian m. carlson wrote:
quoted
I would propose that running `git fetch` should also update remote/HEAD. In
case there is a possibility that it is useful in some cases that remote/HEAD is
actually different from whatever is set in the remote repository as the default
branch, I think a setting for opt-out would be better, and the default
behaviour should be essentially always running `set-head -a`.

My current workaround is an alias:
    fetchall = !git fetch --all && git remote | xargs -i git remote set-head -a {}

which works for me, but I think it would be more elegant not to have to do this.
I believe this would be a valuable change.  I know a lot of other users
want this features as well.  However, I think it needs to be opt-in,
since there are some cases where you want `git fetch` to specifically
fetch only certain objects or don't want to modify the refs. For
example, I know some server-side implementations use `git fetch`
internally and require refs to be updated in a special way, and they
would not appreciate extra refs appearing.
There was discussion a while ago that proposed a tri-state config
option: never update the remote head on fetch, always do so, or add it
only when missing:

  https://lore.kernel.org/git/20201118091219.3341585-1-felipe.contreras@gmail.com/ (local)

I think that is a good first step, as we could stop there and leave the
default at "never" without any compatibility issues (and/or contemplate
a change in the default as a separate step).

I don't think the patch in that thread is likely to go anywhere at this
point, but if somebody wanted to pick it up, I think everybody was
positive on the general direction.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help