git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Fetch origin/HEAD during git fetch

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Oct 9, 2019, 02:24 UTC
Message-ID
<20191009022457.GB73710@google.com>
In-Reply-To
<CAEXP2g8-reK+u2FaO=mMP-nsvuDDWGpwV_tyKG5L5XpU=1LQeg@mail.gmail.com>
Hi!
Dominik Salvet wrote:
Show 9 quoted lines
> 1) `git fetch origin && git remote set-head origin -a`
> 2) `git fetch origin +refs/heads/*:refs/remotes/origin/*
> HEAD:refs/remotes/origin/HEAD`
> 3) instead of git init and remote, use directly `git clone --no-checkout`
>
> The first solution is not suitable due its delay caused by remote
> access (2 separate invocations). For smaller repositories, delays of
> these individual commands are almost comparable. However, this
> solution is semantically exactly what I want.
Interesting.

For the specific case, it sounds like some kind of "git fetch --also-set-head" would do the trick for you. As you can see, I'm awful at naming command line options --- aside from the need to give it a better name, any others thoughts on that? Would you be interested in taking a stab at implementing it?

For the more general case, there's been some discussion of fetching and pushing symrefs on-list before. [1] discusses one possible UI.

[...]
> The third solution has several problems. The first one is the created
> default local branch. So delete it.

Hm, I don't follow. Does "git checkout --orphan" do what you're looking for?

Thanks and hope that helps, Jonathan

[1] https://public-inbox.org/git/20180814214723.GA667@sigill.intra.peff.net/
Previous: Dominik SalvetNext: Dominik Salvet
Message 2 of 3 in “Fetch origin/HEAD during git fetch”
  1. Dominik SalvetOct 9, 2019
  2. Jonathan NiederOct 9, 2019
  3. Dominik SalvetOct 9, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.