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

Re: [PATCH] status: add advice on how to push/pull to tracking branch

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 15, 2012, 17:53 UTC
Message-ID
<7vr4nu92hm.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1352976300-20159-1-git-send-email-Matthieu.Moy@imag.fr>
Matthieu Moy <Matthieu.Moy@imag.fr> writes:
Show 30 quoted lines
> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
> I thought this was obvious enough not to deserve an advice, but a
> colleague of mine had troubles with "commited but not pushed" changes.
> Maybe an additional advice would have helped. After all, it's an
> advice, and can be deactivated ...
>
>  remote.c                   | 13 ++++++++++---
>  t/t2020-checkout-detach.sh |  1 +
>  2 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/remote.c b/remote.c
> index 04fd9ea..9c19689 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -1627,13 +1627,15 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
>  
>  	base = branch->merge[0]->dst;
>  	base = shorten_unambiguous_ref(base, 0);
> -	if (!num_theirs)
> +	if (!num_theirs) {
>  		strbuf_addf(sb,
>  			Q_("Your branch is ahead of '%s' by %d commit.\n",
>  			   "Your branch is ahead of '%s' by %d commits.\n",
>  			   num_ours),
>  			base, num_ours);
> -	else if (!num_ours)
> +		strbuf_addf(sb,
> +			_("  (use \"git push\" to publish your local commits)\n"));
> +	} else if (!num_ours) {

The message should make it clear that the two words in double quotes only hint what command is used to "publish your local commits" and not to be taken as literal "here is what you exactly would type", but I do not think that is what I would get from this if I were a total newbie who would need this advise.

It is even more true given that this is showing an arbitrary, and more likely than not a non-current branch, especially with the recent move from "matching" to "simple" where a naive use of "git push" is to push the branch that is currently checked out and no other branches.

	see 'git push --help' to learn how to publish your local commits
might be more appropriate.
> +		strbuf_addf(sb,
> +			_("  (use \"git pull\" to update your local branch)\n"));
> +	} else {

Likewise, and the non-currentness of the branch being described is even worse in here, as unlike "git push" that can still be used to push a non-current branch, "git pull" is never to be used to update local branch that is not current, which means the advice must mention "git checkout" somewhere.

Previous: Matthieu MoyNext: Matthieu Moy
Message 2 of 5 in “status: add advice on how to push/pull to tracking branch”
  1. status: add advice on how to push/pull to tracking branchMatthieu Moy, Nov 15, 2012
  2. Junio C HamanoNov 15, 2012
  3. Matthieu MoyNov 15, 2012
  4. Junio C HamanoNov 15, 2012
  5. Matthieu MoyNov 16, 2012

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.