Subject: Re: [PATCH v2 1/2] remote: advise about force-pushing as an alternative to reconciliation

From: Junio C Hamano <[email-masked]>
Date: Tue, 04 Jul 2023 14:51:55 -0700

Alex Henrie <[email-masked]> writes:

> Also, don't imply that `git pull` is only for merging.
>
> Signed-off-by: Alex Henrie <[email-masked]>
> ---
>  remote.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/remote.c b/remote.c
> index a81f2e2f17..009034ecde 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -2323,7 +2323,9 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
>  			base, ours, theirs);
>  		if (advice_enabled(ADVICE_STATUS_HINTS))
>  			strbuf_addstr(sb,
> -				_("  (use \"git pull\" to merge the remote branch into yours)\n"));
> +				_("  (use \"git pull\" to reconcile your local branch with the remote branch,\n"
> +				  "  or \"git push --force-with-lease\" to overwrite the remote branch with\n"
> +				  "  your local branch)\n"));
>  	}
>  	free(base);
>  	return 1;

Use of --force-with-lease without which commit you assume to be at
the tip of their branch is just as risky as blind use of --force.

As I said in a separate message, I do not think "reconcile" and
"force" cannot both be sensible choices at the same time.  If the
user wants not to lose the work by themselves and by others,
reconciling would be the only sensible choice and forcing cannot be
a sane substitute for that (if the user knows what is at the tip of
central repository is wrong and wants to get rid of it, forcing
would be a very sensible choice, but then reconciling would not be a
subsitute for that in such a case---"merge --ours" does not count as
"reconciling").

So, I'd suggest to make it a bit more clear that they are not
alternatives in the message, and discourage forcing in the first
place by using not "overwrite" but a bit stronger word, like discard
or destroy.  e.g.

    To reconcile your local changes with the work at the remote, you
    can use 'git pull' and then 'git push'.  To discard the work at
    the remote and replace it with what you did (alone), you can use
    'git push --force'.

or something, perhaps.

Thanks.