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

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

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 2, 2010, 19:12 UTC
Message-ID
<20100802191211.GA2180@burratino>
In-Reply-To
<1280756564-3932-1-git-send-email-Matthieu.Moy@imag.fr>
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
Previous: Matthieu MoyNext: Matthieu Moy
Message 2 of 8 in “push: mention "git pull" in error message for non-fast forwards”
  1. push: mention "git pull" in error message for non-fast forwardsMatthieu Moy, Aug 2, 2010
  2. Jonathan NiederAug 2, 2010
  3. Matthieu MoyAug 2, 2010
  4. Junio C HamanoAug 2, 2010
  5. Matthieu MoyAug 5, 2010
  6. Matthieu MoyAug 12, 2010
  7. Jonathan NiederAug 12, 2010
  8. Matthieu MoyAug 15, 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.