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

[PATCH v2] advice: use global config for default branch name

From
VMVsevolod Myalitsin <ub4nal@mail.ru>
Date
Sep 8, 2026, 21:14 UTC
Message-ID
<20260908211445.37516-1-ub4nal@mail.ru>

The advice for configuring the default branch name suggests disabling it with "git config set advice.defaultBranchName false". This setting is useless because it neither affects the current repository nor newly created repositories.

Suggest using "git config set --global" instead.

To implement this, add a "global_hint" field to the advice_setting struct and explicitly set it to true for defaultBranchName to indicate that the advice should recommend a global configuration. This field can also be used for other advice settings if needed.

Signed-off-by: Vsevolod Myalitsin <ub4nal@mail.ru>
---
 advice.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/advice.c b/advice.c
index 63bf8b0c5f..c3955eeebe 100644
--- a/advice.c
+++ b/advice.c
@@ -42,6 +42,7 @@ enum advice_level {
 
 static struct {
 	const char *key;
+	bool global_hint;
 	enum advice_level level;
 } advice_setting[] = {
 	[ADVICE_ADD_EMBEDDED_REPO]			= { "addEmbeddedRepo" },
@@ -51,7 +52,7 @@ static struct {
 	[ADVICE_AM_WORK_DIR] 				= { "amWorkDir" },
 	[ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME] 	= { "checkoutAmbiguousRemoteBranchName" },
 	[ADVICE_COMMIT_BEFORE_MERGE]			= { "commitBeforeMerge" },
-	[ADVICE_DEFAULT_BRANCH_NAME]			= { "defaultBranchName" },
+	[ADVICE_DEFAULT_BRANCH_NAME]			= { "defaultBranchName", true },
 	[ADVICE_DETACHED_HEAD]				= { "detachedHead" },
 	[ADVICE_DIVERGING]				= { "diverging" },
 	[ADVICE_FETCH_SET_HEAD_WARN]			= { "fetchRemoteHEADWarn" },
@@ -96,10 +97,10 @@ static struct {
 
 static const char turn_off_instructions[] =
 N_("\n"
-   "Disable this message with \"git config set advice.%s false\"");
+   "Disable this message with \"git config set%s advice.%s false\"");
 
 static void vadvise(const char *advice, int display_instructions,
-		    const char *key, va_list params)
+		    const char *key, bool global_hint, va_list params)
 {
 	struct strbuf buf = STRBUF_INIT;
 	const char *cp, *np;
@@ -107,7 +108,8 @@ static void vadvise(const char *advice, int display_instructions,
 	strbuf_vaddf(&buf, advice, params);
 
 	if (display_instructions)
-		strbuf_addf(&buf, turn_off_instructions, key);
+		strbuf_addf(&buf, turn_off_instructions, global_hint ?
+			" --global" : "", key);
 
 	for (cp = buf.buf; *cp; cp = np) {
 		np = strchrnul(cp, '\n');
@@ -126,7 +128,7 @@ void advise(const char *advice, ...)
 {
 	va_list params;
 	va_start(params, advice);
-	vadvise(advice, 0, "", params);
+	vadvise(advice, 0, "", false, params);
 	va_end(params);
 }
 
@@ -156,7 +158,7 @@ void advise_if_enabled(enum advice_type type, const char *advice, ...)
 
 	va_start(params, advice);
 	vadvise(advice, !advice_setting[type].level, advice_setting[type].key,
-		params);
+		advice_setting[type].global_hint, params);
 	va_end(params);
 }
 
-- 
2.50.1
Message 1 of 1 in “advice: use global config for default branch name”
  1. advice: use global config for default branch nameVsevolod Myalitsin, Sep 8, 2026

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.