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

Re: When does git check for branch-X being uptodate with origin/branch-X?

From
Stefan Beller <sbeller@google.com>
Date
Mar 21, 2016, 20:48 UTC
Message-ID
<CAGZ79kbD6hHSnjoQa5Ls0Zo35XLCVQA=XoS9xynfhJrR4qXFWg@mail.gmail.com>
In-Reply-To
<20160321202810.GD32071@sigill.intra.peff.net>
On Mon, Mar 21, 2016 at 1:28 PM, Jeff King <peff@peff.net> wrote:
Show 38 quoted lines
> On Mon, Mar 21, 2016 at 08:21:46PM +0000, Thomas Adam wrote:
>
>> Something I've seen a few times of late (although I doubt that's any
>> indication that the code has changed in Git) is the reporting of
>> branch-X being uptodate with origin/branch-X when it isn't.
>>
>> When does git check to see if branch-X has a remote tracking branch
>> and that it has changes on it?  Only, the output below is misleading:
>>
>> % git checkout master
>> Switched to branch 'master'
>> Your branch is up-to-date with 'fvwmorg/master'.
>>
>> [fvwm-cvs-to-git/docs]{10345}[0][master] % git pull
>> remote: Counting objects: 26, done.
>> remote: Compressing objects: 100% (12/12), done.
>> remote: Total 26 (delta 18), reused 22 (delta 14), pack-reused 0
>> Unpacking objects: 100% (26/26), done.
>> From github.com:fvwmorg/fvwm
>>    c029868..36cc898  master     -> fvwmorg/master
>>    4f0c7ec..36cc898  ta/git-docs -> fvwmorg/ta/git-docs
>> Updating c029868..36cc898
>> Fast-forward
>> [...]
>>
>> Clearly, it's obvious that "Your branch is up-to-date with
>> 'fvwmorg/master'." is misleading.  Note that in this case, there's no
>> passwords or other hindrances to Git being able to work out that a
>> branch is behind another.
>
> The message from checking is looking only at your local
> refs/remotes/fvwmorg/master branch, which is essentially a cache of what
> is in the actual remote repository.
>
> We never contact other repositories unless explicitly asked to by
> fetch, pull, push, etc. If you want to have the most up-to-date value
> without merging, you can just "git fetch" to update the tracking
> branches.
To elaborate on that:

If you do "git fetch" instead of "git pull" and then followed by "git status" it should tell you something like:

    Your branch is behind 'origin/master' by 73 commits, and can be
fast-forwarded.

The origin/ (or in your case fvwmorg/) is a local "cache" on what we think the remote is at. the remote may change of course.

Stefan
Show 6 quoted lines
>
> -Peff
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Philip OakleyNext: Junio C Hamano
Message 15 of 16 in “When does git check for branch-X being uptodate with origin/branch-X?”
  1. Thomas AdamMar 21, 2016
  2. Jeff KingMar 21, 2016
  3. Thomas AdamMar 21, 2016
  4. Junio C HamanoMar 21, 2016
  5. Jeff KingMar 21, 2016
  6. Thomas AdamMar 21, 2016
  7. Jeff KingMar 21, 2016
  8. Thomas AdamMar 21, 2016
  9. Stefan BellerMar 21, 2016
  10. Junio C HamanoMar 21, 2016
  11. Stefan BellerMar 21, 2016
  12. Junio C HamanoMar 21, 2016
  13. Stefan BellerMar 21, 2016
  14. Philip OakleyMar 22, 2016
  15. Stefan BellerMar 21, 2016
  16. Junio C HamanoMar 21, 2016

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.