Hi, these two patches attempt to solve the issue raised in https://lore.kernel.org/git/D3HBD7C1FR14.74FL1Q1S9UCB@xxxxxxxxxxxxxx/ As a quick summary: `clone` sets `refs/remotes/[remote]/HEAD` while going init -> remote add -> fetch does not, one has to manually run `remote set-head -a [remote]`. The first patch adds a `--set-head` flag to `fetch` and `remote update` which runs `remote set-head -a` for us. Unfortunately, with the current behaviour of set-head this will always print a message, even though a no-op fetch doesn't print anything, and I think this is also confusing for people who do not care about remote/HEAD, so the second patch removes the print if `set-head -a` is a no-op (and actually makes it into a no-op, instead of just idempotent). Another way could of course be duplicating some of the code from remote set-head in fetch.c instead of calling directly, but it didn't look like an anti-pattern in the code-base and it felt the best way to insure identical behaviour between a `git fetch --all --set-head` and a `git fetch --all && git remote | xargs -i git remote set-head -a {}`. What is missing for sure is: - documentation - tests (if needed) - settings For settings, my idea would be a fetch/remote.set_head that could take three values: * never * missing: run it only if the ref is missing, this setting would basically allow replicating the result of a clone * always (with the other patch, this would still be a no-op if it didn't change) This would probably also require a --no-set-head flag, to disable an always/missing setting. A --missing-set-head or something of the like also may or may not make sense. Alternatively, only two behaviours might be enough (missing and always) since clone already sort of does this. I'm not sure if the general approach is fine or not, nor am I sure the code itself is any good, but it "works on my computer" :) I'm also hoping that I managed to read all the relevant parts for sending a patch. Feedback would be highly appreciated! Thanks, Bence Bence Ferdinandy (2): fetch: set-head with --set-head option set-head: do not update if there is no change builtin/fetch.c | 29 ++++++++++++++++++++++++----- builtin/remote.c | 15 +++++++++++---- 2 files changed, 35 insertions(+), 9 deletions(-) -- 2.46.0