Re: feature request: set remote/HEAD with fetch
From: brian m. carlson <hidden>
Date: 2024-08-16 21:55:02
On 2024-08-16 at 11:53:31, Bence Ferdinandy wrote:
Hi,
this comes after a bit of discussion on #git. The current behaviour of git is
that when cloning, `refs/remotes/[remote]/HEAD` is set, but if you use `git
init` and `git remote add`, then you must manually run `git remote set-head -a`
to arrive at the same state. Having origin/HEAD set is pretty useful for
scripting and aliases, because you don't need to remember what the current
project uses (origin/[master|main|trunk|etc]).
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. -- brian m. carlson (they/them or he/him) Toronto, Ontario, CA
Attachments
- signature.asc [application/pgp-signature] 262 bytes