threads / patch / 24602

patchpush: mention "git pull" in error message for non-fast forwards

Subject: [PATCH] push: mention "git pull" in error message for non-fast forwards

## tl;dr

8 messages between Aug 2, 2010 and Aug 15, 2010. Diffs are folded; open one to read it.

replies: 7people: 4as markdown or json

Matthieu Moy· Aug 2, 2010, 13:42 UTC · lore

The message remains fuzzy to include "git pull", "git pull --rebase" and others, but directs the user to the simplest solution in the vast majority of cases.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
When the message was added, it was decided explicitely not to say
explicitely "use git pull", first because there are other ways to
merge, and then to encourage the users to read the docs.

After a few months of teaching newbies/students to use Git, the question "it doesn't want to push, what shall I do" still comes in the top questions asked. Each time I've been asked, the newbie's face was enlightened by hearing just the word "pull".

So I guess those few extra characters in the error message would save me a lot of time ;-).

 builtin/push.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Show changes to builtin/push.c +2 −2
diff --git a/builtin/push.c b/builtin/push.c
index f4358b9..69bc2f2 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -130,8 +130,8 @@ static int push_with_options(struct transport *transport, int flags)
 
 	if (nonfastforward && advice_push_nonfastforward) {
 		fprintf(stderr, "To prevent you from losing history, non-fast-forward updates were rejected\n"
-				"Merge the remote changes before pushing again.  See the 'Note about\n"
-				"fast-forwards' section of 'git push --help' for details.\n");
+				"Merge the remote changes (e.g. 'git pull') before pushing again.  See the\n"
+				"'Note about fast-forwards' section of 'git push --help' for details.\n");
 	}
 
 	return 1;
-- 
1.7.2.1.28.g41d92
Jonathan Nieder· Aug 2, 2010, 19:12 UTC · re: Matthieu Moy · lore

Re: [PATCH] push: mention "git pull" in error message for non-fast forwards

Hi Matthieu,
Matthieu Moy wrote:
Show 9 quoted lines
> +++ b/builtin/push.c
> @@ -130,8 +130,8 @@ static int push_with_options(struct transport *transport, int flags)
>  
>  	if (nonfastforward && advice_push_nonfastforward) {
>  		fprintf(stderr, "To prevent you from losing history, non-fast-forward updates were rejected\n"
> -				"Merge the remote changes before pushing again.  See the 'Note about\n"
> -				"fast-forwards' section of 'git push --help' for details.\n");
> +				"Merge the remote changes (e.g. 'git pull') before pushing again.  See the\n"
> +				"'Note about fast-forwards' section of 'git push --help' for details.\n");
Your change is good.

This reminds me: sometimes people blindly “git pull” a rebased history just to avoid a non-fast-forward push, and it irks me to no end. So if I were running the world, the output would be:

 error: rejected non-fast-forward push to '<url>'
 hint: To prevent you from losing history, non-fast-forward updates are
 hint: rejected by default.
 hint: See the 'Note about fast-forwards' section of 'git push --help'
 hint: for details.
and the relevant section of the manual would explain that
 1. if upstream is ahead of you, you may want to "git pull"
but
 2. if upstream rebased, you may want to "git pull --rebase", and
    yell at upstream a little while at it.
and
 3. if the history you are pushing to is both (1) known to be unstable
    and (2) wrong, you can override it with
    "git push <remote> +<refspec>".  Be sure to make sure the
    “[receive] denyNonFastForwards” setting is unset correctly in this
    case.
Jonathan
Matthieu Moy· Aug 2, 2010, 19:52 UTC · re: Jonathan Nieder · lore

Re: [PATCH] push: mention "git pull" in error message for non-fast forwards

Jonathan Nieder <jrnieder@gmail.com> writes:
Show 9 quoted lines
> This reminds me: sometimes people blindly “git pull” a rebased history
> just to avoid a non-fast-forward push, and it irks me to no end.  So if
> I were running the world, the output would be:
>
>  error: rejected non-fast-forward push to '<url>'
>  hint: To prevent you from losing history, non-fast-forward updates are
>  hint: rejected by default.
>  hint: See the 'Note about fast-forwards' section of 'git push --help'
>  hint: for details.
If you were running the world, you'd still need to add stg like
   YES, I DO MEAN IT, RTFM BEFORE ANYTHING ELSE, AND DON'T COMPLAIN
   BEFORE YOU REACH THE END OF THE MANPAGE.
or so, at least if your friends look like my students ;-)
Show 16 quoted lines
> and the relevant section of the manual would explain that
>
>  1. if upstream is ahead of you, you may want to "git pull"
>
> but
>
>  2. if upstream rebased, you may want to "git pull --rebase", and
>     yell at upstream a little while at it.
>
> and
>
>  3. if the history you are pushing to is both (1) known to be unstable
>     and (2) wrong, you can override it with
>     "git push <remote> +<refspec>".  Be sure to make sure the
>     “[receive] denyNonFastForwards” setting is unset correctly in this
>     case.

It's not that far from what the manpage says indeed (it talks about --force instead of +<refspec>, and mentions both pull and pull --rebase). But when the user reached the point where (s)he's wiling to read the doc and finds it interesting, then (s)he'll also read about advice.pushNonFastForward and get rid of the whole (now useless) message ;-).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Junio C Hamano· Aug 2, 2010, 22:11 UTC · re: Jonathan Nieder · lore

Re: [PATCH] push: mention "git pull" in error message for non-fast forwards

Jonathan Nieder <jrnieder@gmail.com> writes:
Show 9 quoted lines
> This reminds me: sometimes people blindly “git pull” a rebased history
> just to avoid a non-fast-forward push, and it irks me to no end.  So if
> I were running the world, the output would be:
>
>  error: rejected non-fast-forward push to '<url>'
>  hint: To prevent you from losing history, non-fast-forward updates are
>  hint: rejected by default.
>  hint: See the 'Note about fast-forwards' section of 'git push --help'
>  hint: for details.
I actually like that ;-)

Since we are discussing the "advice" part of the output, I don't think it is so bad to add the three-bullet list below to it, either, though.

Show 16 quoted lines
>  1. if upstream is ahead of you, you may want to "git pull"
>
> but
>
>  2. if upstream rebased, you may want to "git pull --rebase", and
>     yell at upstream a little while at it.
>
> and
>
>  3. if the history you are pushing to is both (1) known to be unstable
>     and (2) wrong, you can override it with
>     "git push <remote> +<refspec>".  Be sure to make sure the
>     “[receive] denyNonFastForwards” setting is unset correctly in this
>     case.
>
> Jonathan
Matthieu Moy· Aug 5, 2010, 13:14 UTC · re: Junio C Hamano · lore

Re: [PATCH] push: mention "git pull" in error message for non-fast forwards

Junio C Hamano <gitster@pobox.com> writes:
Show 16 quoted lines
> Jonathan Nieder <jrnieder@gmail.com> writes:
>
>> This reminds me: sometimes people blindly “git pull” a rebased history
>> just to avoid a non-fast-forward push, and it irks me to no end.  So if
>> I were running the world, the output would be:
>>
>>  error: rejected non-fast-forward push to '<url>'
>>  hint: To prevent you from losing history, non-fast-forward updates are
>>  hint: rejected by default.
>>  hint: See the 'Note about fast-forwards' section of 'git push --help'
>>  hint: for details.
>
> I actually like that ;-)
>
> Since we are discussing the "advice" part of the output, I don't think it
> is so bad to add the three-bullet list below to it, either, though.

The error message is one that a normal user can see relatively regularly, as soon as he shares a bare-repository with co-workers, so I think it should remain short. That's why I took great care to remain within 3 lines in my patch.

Perhaps the manpage can be improved, but that's a separate topic. My one-line patch would make a great improvement for beginners, without harming advanced users, who still get the pointer to the doc.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Matthieu Moy· Aug 12, 2010, 10:03 UTC · re: Matthieu Moy · lore

Re: [PATCH] push: mention "git pull" in error message for non-fast forwards

Hi,

I'm sorry to insist, but nothing has happened to this patch, and I'd really like it to get merged. The only reaction appart from Junio was Jonathan, and althought it contained a disgression about "if I were running the world", it started with "Your change is good." ;-).

Thanks,
Matthieu Moy <Matthieu.Moy@imag.fr> writes:
Show 36 quoted lines
> The message remains fuzzy to include "git pull", "git pull --rebase" and
> others, but directs the user to the simplest solution in the vast
> majority of cases.
>
> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
> ---
> When the message was added, it was decided explicitely not to say
> explicitely "use git pull", first because there are other ways to
> merge, and then to encourage the users to read the docs.
>
> After a few months of teaching newbies/students to use Git, the
> question "it doesn't want to push, what shall I do" still comes in the
> top questions asked. Each time I've been asked, the newbie's face was
> enlightened by hearing just the word "pull".
>
> So I guess those few extra characters in the error message would save
> me a lot of time ;-).
>
>  builtin/push.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/push.c b/builtin/push.c
> index f4358b9..69bc2f2 100644
> --- a/builtin/push.c
> +++ b/builtin/push.c
> @@ -130,8 +130,8 @@ static int push_with_options(struct transport *transport, int flags)
>  
>  	if (nonfastforward && advice_push_nonfastforward) {
>  		fprintf(stderr, "To prevent you from losing history, non-fast-forward updates were rejected\n"
> -				"Merge the remote changes before pushing again.  See the 'Note about\n"
> -				"fast-forwards' section of 'git push --help' for details.\n");
> +				"Merge the remote changes (e.g. 'git pull') before pushing again.  See the\n"
> +				"'Note about fast-forwards' section of 'git push --help' for details.\n");
>  	}
>  
>  	return 1;
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Jonathan Nieder· Aug 12, 2010, 19:28 UTC · re: Matthieu Moy · lore

Re: [PATCH] push: mention "git pull" in error message for non-fast forwards

Matthieu Moy wrote:
> I'm sorry to insist, but nothing has happened to this patch, and I'd
> really like it to get merged. The only reaction appart from Junio was
> Jonathan, and althought it contained a disgression about "if I were
> running the world", it started with "Your change is good." ;-).
Indeed.  To be clear, I like your change. ;-)
Matthieu Moy· Aug 15, 2010, 17:34 UTC · re: Matthieu Moy · lore

Re: [PATCH] push: mention "git pull" in error message for non-fast forwards

Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
Show 6 quoted lines
> Hi,
>
> I'm sorry to insist, but nothing has happened to this patch, and I'd
> really like it to get merged. The only reaction appart from Junio was
> Jonathan, and althought it contained a disgression about "if I were
> running the world", it started with "Your change is good." ;-).
It got merged into master. Thanks, Junio!
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

← back to recent threads