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

Re: confused about remote branch management

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 23, 2014, 23:51 UTC
Message-ID
<xmqqvbqnab1n.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1406158252.29001.223.camel@localhost>
Ross Boylan <ross@biostat.ucsf.edu> writes:
Show 6 quoted lines
>> Either
>> 
>> 	git fetch origin master:refs/remotes/origin/master
> Great; that works.
> Is that procedure supposed to be the usual way I track upstream in this
> (1.7) version of git?  It seems arcane.

No, and no. The command is designed so that most of the time you can just say "git fetch<ENTER>" without anything extra, which will let the configured remote.*.fetch to kick in as the default refspec to slurp updates to all the branches. This is because the branches of a single project are supposed to be related, and a single "git fetch" goes over a single network connection, establishment of which is expected to be a large overhead. Letting a single invocation of "fetch" to slurp updates to _all_ the branches is supposed not to be too much overhead over grabbing updates to everything (let alone invoking a "git fetch" per each individual branch), and is the normal mode of operation.

A single-shot "git fetch origin master" to explicitly decline following of everything other than 'master' *is* the special case.

And it was a very conscious design decision not to molest the remote tracking branch when this kind of explicit command line request is made, so that you do not lose track of what commit you _saw_ before you ran the command. That way "git log origin/master..FETCH_HEAD" can be used to inspect what got changed since you fetched last time.

Over the years, with reflogs enabled for everybody, preserving the remote tracking branches when the user does not explicitly ask to store the result has become much less important. For this reason, modern Git applies, when it sees "git fetch origin master", the configured remote.*.fetch as refmap to map the name "master", i.e. the only branch you are fetching, to the remote tracking branch you use to store the result, i.e. "refs/remotes/origin/master".

Previous: Ross BoylanNext: Ross Boylan
Message 6 of 9 in “confused about remote branch management”
  1. Ross BoylanJul 23, 2014
  2. Chris PackhamJul 23, 2014
  3. Ross BoylanJul 23, 2014
  4. Junio C HamanoJul 23, 2014
  5. Ross BoylanJul 23, 2014
  6. Junio C HamanoJul 23, 2014
  7. Ross BoylanJul 24, 2014
  8. KevinJul 23, 2014
  9. Ross BoylanJul 23, 2014

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.