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

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

From
ESEugene Sajine <euguess@gmail.com>
Date
Jun 8, 2010, 16:27 UTC
Message-ID
<AANLkTinLVd483-ki6tVb545PgpOFeOLYLR_GiKM5xAl7@mail.gmail.com>
In-Reply-To
<7v7hrtzbau.fsf@alter.siamese.dyndns.org>
On Thu, Jan 7, 2010 at 8:32 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 42 quoted lines
> Eugene Sajine <euguess@gmail.com> writes:
>
>> $ 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.
>
>

I'm coming back to this topic as i see some confusion growing about such behavior. Every now and then users come across this problem and they expect pull to *really* behave as fetch and merge so it will cause the update of remote/branchname branch. And it is kind of difficult to justify why they have to do git fetch after pull...

Can somebody, please, take a look?

Thanks, Eugene

Previous: Junio C HamanoNext: Junio C Hamano
Message 7 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.