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

Re: a more helpful message on "git status" output

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 18, 2014, 19:29 UTC
Message-ID
<xmqq38dympo8.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAKQhN+rK0ftwC5hX4hDhXZbcEGAfCCBXRaQXYnMFLmR=n21OLA@mail.gmail.com>
Julián Landerreche <maniqui@gmail.com> writes:
Show 15 quoted lines
> when running "git status", if the current branch can be
> fast-forwarded, the user get this message:
>
>   On branch master
>   Your branch is behind 'origin/master' by 6 commits, and can be fast-forwarded.
>     (use "git pull" to update your local branch)
>
> The suggestion of using "git pull" for updating the local branch,
> although it will work, might not be a proper choice or advice in terms
> of what is really needed to just update the local branch.
>
> As the user already has the newer commits locally (ie. the commits
> have been already "git fetch"ed), he just needs to merge them. Running
> "git pull" will unnecessarily try to fetch commits from upstream
> again.

By running "git pull", the user may obtain yet newer commits from the upstream, which very likely will happen in an active project, or "git fetch" launched by "git pull" will return without doing anything after noticing there is nothing new.

As long as the updates to the upstream is also a fast-forward, it will still fast-forward you, but to an even newer state of the upstream.

There is no harm done[*1*] by suggesting "git pull" over "git merge", no?

[Footnote]

*1* There is a bigger problem with this message, especially when the user sees it on 'master', but your message is about the case where you are strictly behind and that bigger problem will not be an issue, so I won't discuss it further.

Previous: Julián LanderrecheNext: Julián Landerreche
Message 2 of 6 in “a more helpful message on "git status" output”
  1. Julián LanderrecheJul 18, 2014
  2. Junio C HamanoJul 18, 2014
  3. Julián LanderrecheJul 18, 2014
  4. Jonathan NiederJul 18, 2014
  5. Junio C HamanoJul 18, 2014
  6. Matthieu MoyJul 21, 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.