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

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

From
Alex Henrie <alexhenrie24@gmail.com>
Date
Jul 7, 2023, 05:42 UTC
Message-ID
<20230707054257.3366355-2-alexhenrie24@gmail.com>
In-Reply-To
<20230707054257.3366355-1-alexhenrie24@gmail.com>
Also, don't imply that `git pull` is only for merging.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
 remote.c          |   5 ++-
 t/t7508-status.sh | 110 ++++++++++++++++++++++++++++++++++++----------
 2 files changed, 92 insertions(+), 23 deletions(-)
diff --git a/remote.c b/remote.c
index a81f2e2f17..1fe86f8b23 100644
--- a/remote.c
+++ b/remote.c
@@ -2323,7 +2323,10 @@ 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"));
+				_("  (To reconcile your local changes with the work at the remote, you can\n"
+				  "  use 'git pull' and then 'git push'. To discard the work at the remote\n"
+				  "  and replace it with what you did (alone), you can use\n"
+				  "  'git push --force'.)\n"));
 	}
 	free(base);
 	return 1;
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 36567708f5..2a17e84793 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -92,7 +92,10 @@ test_expect_success 'status --column' '
 # On branch main
 # Your branch and '\''upstream'\'' have diverged,
 # and have 1 and 2 different commits each, respectively.
-#   (use "git pull" to merge the remote branch into yours)
+#   (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'\''.)
 #
 # Changes to be committed:
 #   (use "git restore --staged <file>..." to unstage)
@@ -123,7 +126,10 @@ cat >expect <<\EOF
 # On branch main
 # Your branch and 'upstream' have diverged,
 # and have 1 and 2 different commits each, respectively.
-#   (use "git pull" to merge the remote branch into yours)
+#   (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'.)
 #
 # Changes to be committed:
 #   (use "git restore --staged <file>..." to unstage)
@@ -270,7 +276,10 @@ test_expect_success 'status with gitignore' '
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 1 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -335,7 +344,10 @@ test_expect_success 'status with gitignore (nothing untracked)' '
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 1 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -405,7 +417,10 @@ test_expect_success 'status -uno' '
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 1 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -467,7 +482,10 @@ test_expect_success 'status -unormal' '
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 1 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -522,7 +540,10 @@ test_expect_success 'status -uall' '
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 1 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -582,7 +603,10 @@ test_expect_success 'status with relative paths' '
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 1 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -650,7 +674,10 @@ test_expect_success TTY 'status with color.ui' '
 On branch <GREEN>main<RESET>
 Your branch and '\''upstream'\'' have diverged,
 and have 1 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -773,7 +800,10 @@ test_expect_success 'status without relative paths' '
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 1 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -847,7 +877,10 @@ test_expect_success 'dry-run of partial commit excluding new file in index' '
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 1 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -901,7 +934,10 @@ test_expect_success 'status submodule summary is disabled by default' '
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 1 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -958,7 +994,10 @@ test_expect_success 'status submodule summary' '
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 1 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -1017,7 +1056,10 @@ test_expect_success 'status submodule summary (clean submodule): commit' '
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 2 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes not staged for commit:
   (use "git add <file>..." to update what will be committed)
@@ -1065,7 +1107,10 @@ test_expect_success 'commit --dry-run submodule summary (--amend)' '
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 2 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --source=HEAD^1 --staged <file>..." to unstage)
@@ -1117,7 +1162,10 @@ test_expect_success '--ignore-submodules=untracked suppresses submodules with un
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 2 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -1226,7 +1274,10 @@ test_expect_success "--ignore-submodules=untracked doesn't suppress submodules w
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 2 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -1283,7 +1334,10 @@ test_expect_success "--ignore-submodules=untracked doesn't suppress submodule su
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 2 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -1364,7 +1418,10 @@ cat > expect << EOF
 ; On branch main
 ; Your branch and 'upstream' have diverged,
 ; and have 2 and 2 different commits each, respectively.
-;   (use "git pull" to merge the remote branch into yours)
+;   (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'.)
 ;
 ; Changes to be committed:
 ;   (use "git restore --staged <file>..." to unstage)
@@ -1412,7 +1469,10 @@ test_expect_success "--ignore-submodules=all suppresses submodule summary" '
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 2 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes not staged for commit:
   (use "git add <file>..." to update what will be committed)
@@ -1438,7 +1498,10 @@ test_expect_success '.gitmodules ignore=all suppresses unstaged submodule summar
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 2 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
@@ -1558,7 +1621,10 @@ test_expect_success 'git commit --dry-run will show a staged but ignored submodu
 On branch main
 Your branch and '\''upstream'\'' have diverged,
 and have 2 and 2 different commits each, respectively.
-  (use "git pull" to merge the remote branch into yours)
+  (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'\''.)
 
 Changes to be committed:
   (use "git restore --staged <file>..." to unstage)
-- 
2.41.0
Previous: Alex HenrieNext: Alex Henrie
Message 38 of 45 in “advise about force-pushing as an alternative to reconciliation”
  1. 0/2 advise about force-pushing as an alternative to reconciliationAlex Henrie, Jul 2, 2023
  2. 2/2 push: advise about force-pushing as an alternative to reconciliationAlex Henrie, Jul 2, 2023
  3. 1/2 remote: advise about force-pushing as an alternative to reconciliationAlex Henrie, Jul 2, 2023
  4. Phillip WoodJul 3, 2023
  5. Alex HenrieJul 3, 2023
  6. Junio C HamanoJul 4, 2023
  7. Alex HenrieJul 4, 2023
  8. Junio C HamanoJul 5, 2023
  9. Alex HenrieJul 6, 2023
  10. 0/2 advise about force-pushing as an alternative to reconciliationAlex Henrie, Jul 4, 2023
  11. 2/2 push: advise about force-pushing as an alternative to reconciliationAlex Henrie, Jul 4, 2023
  12. 1/2 remote: advise about force-pushing as an alternative to reconciliationAlex Henrie, Jul 4, 2023
  13. Junio C HamanoJul 4, 2023
  14. Alex HenrieJul 4, 2023
  15. 0/2 advise about force-pushing as an alternative to reconciliationAlex Henrie, Jul 6, 2023
  16. 1/2 remote: advise about force-pushing as an alternative to reconciliationAlex Henrie, Jul 6, 2023
  17. Junio C HamanoJul 6, 2023
  18. Junio C HamanoJul 6, 2023
  19. Alex HenrieJul 6, 2023
  20. Junio C HamanoJul 7, 2023
  21. Junio C HamanoJul 7, 2023
  22. Alex HenrieJul 8, 2023
  23. Junio C HamanoJul 9, 2023
  24. Alex HenrieJul 10, 2023
  25. Junio C HamanoJul 11, 2023
  26. Alex HenrieJul 12, 2023
  27. Junio C HamanoJul 12, 2023
  28. Alex HenrieJul 13, 2023
  29. Phillip WoodJul 7, 2023
  30. 2/2 push: advise about force-pushing as an alternative to reconciliationAlex Henrie, Jul 6, 2023
  31. Phillip WoodJul 7, 2023
  32. Junio C HamanoJul 7, 2023
  33. Alex HenrieJul 8, 2023
  34. Phillip WoodJul 11, 2023
  35. Alex HenrieJul 12, 2023
  36. Alex HenrieJul 12, 2023
  37. 0/2 advise about force-pushing as an alternative to reconciliationAlex Henrie, Jul 7, 2023
  38. 1/2 remote: advise about force-pushing as an alternative to reconciliationAlex Henrie, Jul 7, 2023
  39. 2/2 push: advise about force-pushing as an alternative to reconciliationAlex Henrie, Jul 7, 2023
  40. 0/3 don't imply that integration is always required before pushingAlex Henrie, Jul 13, 2023
  41. 1/3 wt-status: don't show divergence advice when committingAlex Henrie, Jul 13, 2023
  42. 2/3 remote: don't imply that integration is always required before pushingAlex Henrie, Jul 13, 2023
  43. 3/3 push: don't imply that integration is always required before pushingAlex Henrie, Jul 13, 2023
  44. Phillip WoodJul 13, 2023
  45. Junio C HamanoJul 13, 2023

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.