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

Re: Update message_advice_pull_before_push to mention how to push after rebasing

From
Rubén Justo <rjusto@gmail.com>
Date
Mar 28, 2024, 11:49 UTC
Message-ID
<8d226216-9a80-471e-9d7b-3ca8d21c1e05@gmail.com>
In-Reply-To
<CAK_130T8sZUZAuvj4x7sB278kVL7ARaBv3Pg2djQB45O+7xKTg@mail.gmail.com>
On Thu, Mar 28, 2024 at 05:54:13PM +0800, zhang kai wrote:
Show 20 quoted lines
> Hi all,
> 
> Our team uses git rebase a lot. A common hiccup we noticed during the
> daily work is that new devs often didn't know how to push properly
> after the rebase.
> 
> When someone try to push to the remote after rebasing the branch, the
> push would mostly fail with the message_advice_pull_before_push:
> 
> > Updates were rejected because the tip of your current branch is behind\n" "its remote counterpart. If you want to integrate the remote changes,\n" "use 'git pull' before pushing again.\n" "See the 'Note about fast-forwards' in 'git push --help' for details.
> 
> However, in this situation, pull will "invalid" the rebasing. After
> pull then push, devs often will be surprised by the merge/pull request
> containing diffs that should not be in this branch. In this case, we
> often should just do `git push --force-with-lease`.
> 
> If we add a message like "If you just rebased your branch, please
> consider 'git push --force-with-lease'" to the
> message_adivce_pull_before_push, we may save devs some time figuring
> out what's wrong with their branch.
It does sound sensible ...
> If this is acceptable, we'd be
> happy to prepare a patch.

... but you should better expect acceptance after sending a concrete series that makes the objective clear ;)

I see that we are using, in builtin/push.c, the form:
	if (advice_enabled(XXX))
		advise(YYY)

It would be well received, I think, if your proposal includes a change for that, to start using the now preferred advise_if_enabled() mechanism.

Of course, this is entirely optional and does not need to be done in the context of this hypothetical series.

Thanks.
Previous: zhang kaiNext: Junio C Hamano
Message 2 of 6 in “Update message_advice_pull_before_push to mention how to push after rebasing”
  1. zhang kaiMar 28, 2024
  2. Rubén JustoMar 28, 2024
  3. Junio C HamanoMar 28, 2024
  4. zhang kaiMar 28, 2024
  5. Junio C HamanoMar 28, 2024
  6. zhang kaiMar 29, 2024

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.