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

[PATCH v2 02/13] pull: improve default warning

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Dec 18, 2020, 21:10 UTC
Message-ID
<20201218211026.1937168-3-felipe.contreras@gmail.com>
In-Reply-To
<20201218211026.1937168-1-felipe.contreras@gmail.com>

According to feedback from GitHub trainers [1], most newcomers don't understand what a rebase is. So in the default warning we want to provide our users with a command that does the most sensible thing, fixes the divergence, gets rid of the warning, with the minimum mental effort, and happens to be the default:

  git pull --no-rebase (later --merge)

In addition, we don't want to start by recommending a permanent configuration, but a temporary solution so they start training their fingers and maybe learn how to do a rebase. So we start with the commands.

Also, we need to be clear about what we mean by "specifying"; merge, or rebase.

Moreover, thanks to the previous patch now "git pull --help" explains what a fast-forward is, let's mention that reference.

And finally, use --global in the configuration commands like we did with push.default.

[1] https://lore.kernel.org/git/20130909201751.GA14437@sigill.intra.peff.net/
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin/pull.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/builtin/pull.c b/builtin/pull.c
index e8927fc2ff..a766d9762c 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -927,18 +927,20 @@ static int get_can_ff(struct object_id *orig_head, struct object_id *orig_merge_
 
 static void show_advice_pull_non_ff(void)
 {
-	advise(_("Pulling without specifying how to reconcile divergent branches is\n"
-		 "discouraged. You can squelch this message by running one of the following\n"
-		 "commands sometime before your next pull:\n"
+	advise(_("Pulling without specifying how to reconcile divergent branches is discouraged;\n"
+		 "you need to specify if you want a merge, or a rebase.\n"
 		 "\n"
-		 "  git config pull.rebase false  # merge (the default strategy)\n"
-		 "  git config pull.rebase true   # rebase\n"
-		 "  git config pull.ff only       # fast-forward only\n"
+		 "  git pull --no-rebase # the default (merge)\n"
+		 "  git pull --rebase\n"
 		 "\n"
-		 "You can replace \"git config\" with \"git config --global\" to set a default\n"
-		 "preference for all repositories. You can also pass --rebase, --no-rebase,\n"
-		 "or --ff-only on the command line to override the configured default per\n"
-		 "invocation.\n"));
+		 "You can squelch this message by running one of the following commands:\n"
+		 "\n"
+		 "  git config --global pull.rebase false  # merge\n"
+		 "  git config --global pull.rebase true   # rebase\n"
+		 "  git config --global pull.ff only       # fast-forward only\n"
+		 "\n"
+		 "If unsure, run \"git pull --no-rebase\".\n"
+		 "Read \"git pull --help\" for more information."));
 }
 
 int cmd_pull(int argc, const char **argv, const char *prefix)
-- 
2.30.0.rc0
Previous: Felipe ContrerasNext: Felipe Contreras
Message 3 of 14 in “pull: pull mode part 2”
  1. 00/13 pull: pull mode part 2Felipe Contreras, Dec 18, 2020
  2. 01/13 doc: pull: explain what is a fast-forwardFelipe Contreras, Dec 18, 2020
  3. 02/13 pull: improve default warningFelipe Contreras, Dec 18, 2020
  4. 04/13 pull: trivial cleanupFelipe Contreras, Dec 18, 2020
  5. 03/13 pull: cleanup autostash checkFelipe Contreras, Dec 18, 2020
  6. 05/13 pull: trivial whitespace style fixFelipe Contreras, Dec 18, 2020
  7. 06/13 pull: introduce --merge optionFelipe Contreras, Dec 18, 2020
  8. 07/13 rebase: add REBASE_DEFAULTFelipe Contreras, Dec 18, 2020
  9. 09/13 pull: show warning with --ff optionsFelipe Contreras, Dec 18, 2020
  10. 08/13 pull: move configurations fetchesFelipe Contreras, Dec 18, 2020
  11. 10/13 pull: add pull.modeFelipe Contreras, Dec 18, 2020
  12. 12/13 pull: reorganize mode conditionalsFelipe Contreras, Dec 18, 2020
  13. 13/13 pull: improve --rebase and pull.rebase interactionFelipe Contreras, Dec 18, 2020
  14. 11/13 pull: add pull.mode=fast-forwardFelipe Contreras, Dec 18, 2020

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.