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

Re: origin/branchname and tracking branch pointing to different commits?

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 8, 2010, 00:32 UTC
Message-ID
<7v7hrtzbau.fsf@alter.siamese.dyndns.org>
In-Reply-To
<76c5b8581001071550g31e9f5a3n15ebdb10a806ab2e@mail.gmail.com>
Eugene Sajine <euguess@gmail.com> writes:
Show 14 quoted lines
> $ git fetch origin branchname
>
> are both causing the output like this:
>
> From git://....
> * branch      branchname    -> FETCH_HEAD
> ...
>
> but "git fetch" says:
>
> From git://....
> * branch      branchname    -> origin/branchname
>
> Is this inconsistent behavior necessary by design?
It is by design; it is debatable if it still makes sense, though.

Back when "git fetch" was invented, there weren't separate refs/remotes/ hierarchy, the distinction between what's local and what's remote were only in user's head. It made quite a lot of sense to have an explicit way to prevent "fetch" from overwriting all the branches that track branches from remote. Suppose you have already spend considerable time inspecting 'origin/branch' and decided that has a suitable commit to build your changes on, but you needed to work on something else first. If "git fetch origin other", an explicit request about "other" branch, updated an unrelated "origin/branch" at the same time, you couldn't recover from it by using "origin/branch@{1}", because reflog is a fairly recent invention.

An explicit "git fetch origin other" is a way to prevent such an update from happening. It does not update anything in refs/ hierarchy, even when you have configured to make an implicit 'git fetch $there' make a copy of $this_ref somewhere in your refs/remotes/$there/ hierarchy in .git/config (back then the same information came from .git/remotes).

Because we have reflogs on by default, and refs/remotes/ is a separate hierarchy that is read-only from the local user's point of view, I think the 'explicit fetch' syntax, as a way to stop tracking branches from getting updated, ceased to be useful these days.

Previous: Eugene SajineNext: Eugene Sajine
Message 6 of 14 in “origin/branchname and tracking branch pointing to different commits?”
  1. Eugene SajineJan 7, 2010
  2. Matthieu MoyJan 7, 2010
  3. Thomas RastJan 7, 2010
  4. Eugene SajineJan 7, 2010
  5. Eugene SajineJan 7, 2010
  6. Junio C HamanoJan 8, 2010
  7. Eugene SajineJun 8, 2010
  8. Junio C HamanoJun 8, 2010
  9. Eugene SajineJun 8, 2010
  10. Jeff KingJun 8, 2010
  11. Eugene SajineJun 28, 2010
  12. Junio C HamanoJun 29, 2010
  13. Eugene SajineJun 29, 2010
  14. Jeff KingJun 29, 2010

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.