remote: don't imply that integration is always required before pushing

In a narrow but common case, the user is the only author of a branch and doesn't mind overwriting the corresponding branch on the remote. This workflow is especially common on GitHub, GitLab, and Gerrit, which keep a permanent record of every version of a branch that is pushed while a pull request is open for that branch. On those platforms, force-pushing is encouraged and is analogous to emailing a new version of a patchset. When giving advice about divergent branches, tell the user about `git pull`, but don't unconditionally instruct the user to do it. A less prescriptive message will help prevent users from thinking that they are required to create an integrated history instead of simply replacing the previous history. Likewise, don't imply that `git pull` is only for merging. Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alex Henrie committed Jul 12, 2023 at 22:41 UTC d92304ff5cfdca463e9ecd1345807d0b46d6af33
2 files changed +20 -20
remote.c
+1 -1
@@ -2325,7 +2325,7 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb,
2325 if (show_divergence_advice &&
2326 advice_enabled(ADVICE_STATUS_HINTS))
2327 strbuf_addstr(sb,
2328 - _(" (use \"git pull\" to merge the remote branch into yours)\n"));
2328 + _(" (use \"git pull\" if you want to integrate the remote branch with yours)\n"));
2329 }
2330 free(base);
2331 return 1;
t/t7508-status.sh
+19 -19
@@ -92,7 +92,7 @@ test_expect_success 'status --column' '
92 # On branch main
93 # Your branch and '\''upstream'\'' have diverged,
94 # and have 1 and 2 different commits each, respectively.
95 -# (use "git pull" to merge the remote branch into yours)
95 +# (use "git pull" if you want to integrate the remote branch with yours)
96 #
97 # Changes to be committed:
98 # (use "git restore --staged <file>..." to unstage)
@@ -123,7 +123,7 @@ cat >expect <<\EOF
123 # On branch main
124 # Your branch and 'upstream' have diverged,
125 # and have 1 and 2 different commits each, respectively.
126 -# (use "git pull" to merge the remote branch into yours)
126 +# (use "git pull" if you want to integrate the remote branch with yours)
127 #
128 # Changes to be committed:
129 # (use "git restore --staged <file>..." to unstage)
@@ -270,7 +270,7 @@ test_expect_success 'status with gitignore' '
270 On branch main
271 Your branch and '\''upstream'\'' have diverged,
272 and have 1 and 2 different commits each, respectively.
273 - (use "git pull" to merge the remote branch into yours)
273 + (use "git pull" if you want to integrate the remote branch with yours)
274
275 Changes to be committed:
276 (use "git restore --staged <file>..." to unstage)
@@ -335,7 +335,7 @@ test_expect_success 'status with gitignore (nothing untracked)' '
335 On branch main
336 Your branch and '\''upstream'\'' have diverged,
337 and have 1 and 2 different commits each, respectively.
338 - (use "git pull" to merge the remote branch into yours)
338 + (use "git pull" if you want to integrate the remote branch with yours)
339
340 Changes to be committed:
341 (use "git restore --staged <file>..." to unstage)
@@ -405,7 +405,7 @@ test_expect_success 'status -uno' '
405 On branch main
406 Your branch and '\''upstream'\'' have diverged,
407 and have 1 and 2 different commits each, respectively.
408 - (use "git pull" to merge the remote branch into yours)
408 + (use "git pull" if you want to integrate the remote branch with yours)
409
410 Changes to be committed:
411 (use "git restore --staged <file>..." to unstage)
@@ -467,7 +467,7 @@ test_expect_success 'status -unormal' '
467 On branch main
468 Your branch and '\''upstream'\'' have diverged,
469 and have 1 and 2 different commits each, respectively.
470 - (use "git pull" to merge the remote branch into yours)
470 + (use "git pull" if you want to integrate the remote branch with yours)
471
472 Changes to be committed:
473 (use "git restore --staged <file>..." to unstage)
@@ -522,7 +522,7 @@ test_expect_success 'status -uall' '
522 On branch main
523 Your branch and '\''upstream'\'' have diverged,
524 and have 1 and 2 different commits each, respectively.
525 - (use "git pull" to merge the remote branch into yours)
525 + (use "git pull" if you want to integrate the remote branch with yours)
526
527 Changes to be committed:
528 (use "git restore --staged <file>..." to unstage)
@@ -582,7 +582,7 @@ test_expect_success 'status with relative paths' '
582 On branch main
583 Your branch and '\''upstream'\'' have diverged,
584 and have 1 and 2 different commits each, respectively.
585 - (use "git pull" to merge the remote branch into yours)
585 + (use "git pull" if you want to integrate the remote branch with yours)
586
587 Changes to be committed:
588 (use "git restore --staged <file>..." to unstage)
@@ -650,7 +650,7 @@ test_expect_success TTY 'status with color.ui' '
650 On branch <GREEN>main<RESET>
651 Your branch and '\''upstream'\'' have diverged,
652 and have 1 and 2 different commits each, respectively.
653 - (use "git pull" to merge the remote branch into yours)
653 + (use "git pull" if you want to integrate the remote branch with yours)
654
655 Changes to be committed:
656 (use "git restore --staged <file>..." to unstage)
@@ -773,7 +773,7 @@ test_expect_success 'status without relative paths' '
773 On branch main
774 Your branch and '\''upstream'\'' have diverged,
775 and have 1 and 2 different commits each, respectively.
776 - (use "git pull" to merge the remote branch into yours)
776 + (use "git pull" if you want to integrate the remote branch with yours)
777
778 Changes to be committed:
779 (use "git restore --staged <file>..." to unstage)
@@ -900,7 +900,7 @@ test_expect_success 'status submodule summary is disabled by default' '
900 On branch main
901 Your branch and '\''upstream'\'' have diverged,
902 and have 1 and 2 different commits each, respectively.
903 - (use "git pull" to merge the remote branch into yours)
903 + (use "git pull" if you want to integrate the remote branch with yours)
904
905 Changes to be committed:
906 (use "git restore --staged <file>..." to unstage)
@@ -957,7 +957,7 @@ test_expect_success 'status submodule summary' '
957 On branch main
958 Your branch and '\''upstream'\'' have diverged,
959 and have 1 and 2 different commits each, respectively.
960 - (use "git pull" to merge the remote branch into yours)
960 + (use "git pull" if you want to integrate the remote branch with yours)
961
962 Changes to be committed:
963 (use "git restore --staged <file>..." to unstage)
@@ -1016,7 +1016,7 @@ test_expect_success 'status submodule summary (clean submodule): commit' '
1016 On branch main
1017 Your branch and '\''upstream'\'' have diverged,
1018 and have 2 and 2 different commits each, respectively.
1019 - (use "git pull" to merge the remote branch into yours)
1019 + (use "git pull" if you want to integrate the remote branch with yours)
1020
1021 Changes not staged for commit:
1022 (use "git add <file>..." to update what will be committed)
@@ -1116,7 +1116,7 @@ test_expect_success '--ignore-submodules=untracked suppresses submodules with un
1116 On branch main
1117 Your branch and '\''upstream'\'' have diverged,
1118 and have 2 and 2 different commits each, respectively.
1119 - (use "git pull" to merge the remote branch into yours)
1119 + (use "git pull" if you want to integrate the remote branch with yours)
1120
1121 Changes to be committed:
1122 (use "git restore --staged <file>..." to unstage)
@@ -1225,7 +1225,7 @@ test_expect_success "--ignore-submodules=untracked doesn't suppress submodules w
1225 On branch main
1226 Your branch and '\''upstream'\'' have diverged,
1227 and have 2 and 2 different commits each, respectively.
1228 - (use "git pull" to merge the remote branch into yours)
1228 + (use "git pull" if you want to integrate the remote branch with yours)
1229
1230 Changes to be committed:
1231 (use "git restore --staged <file>..." to unstage)
@@ -1282,7 +1282,7 @@ test_expect_success "--ignore-submodules=untracked doesn't suppress submodule su
1282 On branch main
1283 Your branch and '\''upstream'\'' have diverged,
1284 and have 2 and 2 different commits each, respectively.
1285 - (use "git pull" to merge the remote branch into yours)
1285 + (use "git pull" if you want to integrate the remote branch with yours)
1286
1287 Changes to be committed:
1288 (use "git restore --staged <file>..." to unstage)
@@ -1363,7 +1363,7 @@ cat > expect << EOF
1363 ; On branch main
1364 ; Your branch and 'upstream' have diverged,
1365 ; and have 2 and 2 different commits each, respectively.
1366 -; (use "git pull" to merge the remote branch into yours)
1366 +; (use "git pull" if you want to integrate the remote branch with yours)
1367 ;
1368 ; Changes to be committed:
1369 ; (use "git restore --staged <file>..." to unstage)
@@ -1411,7 +1411,7 @@ test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1411 On branch main
1412 Your branch and '\''upstream'\'' have diverged,
1413 and have 2 and 2 different commits each, respectively.
1414 - (use "git pull" to merge the remote branch into yours)
1414 + (use "git pull" if you want to integrate the remote branch with yours)
1415
1416 Changes not staged for commit:
1417 (use "git add <file>..." to update what will be committed)
@@ -1437,7 +1437,7 @@ test_expect_success '.gitmodules ignore=all suppresses unstaged submodule summar
1437 On branch main
1438 Your branch and '\''upstream'\'' have diverged,
1439 and have 2 and 2 different commits each, respectively.
1440 - (use "git pull" to merge the remote branch into yours)
1440 + (use "git pull" if you want to integrate the remote branch with yours)
1441
1442 Changes to be committed:
1443 (use "git restore --staged <file>..." to unstage)