diff --git a/remote.c b/remote.c index 89d142cc7e..af8d026073 100644 --- a/remote.c +++ b/remote.c @@ -2468,7 +2468,7 @@ static void format_branch_comparison(struct strbuf *sb, _(" (use \"git pull\" to update your local branch)\n")); } } else { - if (same_changes) + if (same_changes) { strbuf_addf(sb, Q_("Your branch and '%s' have diverged,\n" "and have %d and %d different commit each " @@ -2478,7 +2478,10 @@ static void format_branch_comparison(struct strbuf *sb, "(rebased cleanly on '%s').\n", ours + theirs), branch_name, ours, theirs, upstream_name); - else if (upstream_name) + if (use_push_advice && advice_enabled(ADVICE_STATUS_HINTS)) + strbuf_addstr(sb, + _(" (use \"git push --force-with-lease\" to publish your local commits)\n")); + } else if (upstream_name) strbuf_addf(sb, Q_("Your branch and '%s' have diverged,\n" "and have %d and %d different commit each " diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh index 2ebc3573da..4074c6663a 100755 --- a/t/t6040-tracking-info.sh +++ b/t/t6040-tracking-info.sh @@ -802,6 +802,7 @@ test_expect_success 'status.compareBranches after a clean rebase of the push bra Your branch and ${SQ}origin/feature19${SQ} have diverged, and have 3 and 1 different commits each (rebased cleanly on ${SQ}origin/main${SQ}). + (use "git push --force-with-lease" to publish your local commits) nothing to commit, working tree clean EOF