From: "Wing Huang via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Wing Huang <huangsen365@gmail.com>, Wing Huang <huangsen365@gmail.com>
Subject: [PATCH] rename default branch from 'master' to 'main' in refs and test scripts
Date: Tue, 26 Aug 2025 04:52:01 +0000 [thread overview]
Message-ID: <pull.1961.git.1756183921623.gitgitgadget@gmail.com> (raw)
From: Wing Huang <huangsen365@gmail.com>
Signed-off-by: Wing Huang <huangsen365@gmail.com>
modified: refs.c
modified: remote.c
modified: t/test-lib.sh
---
rename default branch from 'master' to 'main' in refs and test scripts
This patch updates Git's default branch name from 'master' to 'main' to
align with modern naming conventions adopted across the industry.
The change affects only newly initialized repositories and maintains
full backward compatibility through the existing init.defaultBranch
configuration option.
Changes made:
* refs.c: Update hardcoded default branch name to 'main'
* remote.c: Update fallback branch name for remote operations
* t/test-lib.sh: Update test suite default to 'main'
Compatibility notes:
* Existing repositories are unaffected
* Users can still set init.defaultBranch=master if preferred
* The change only applies to new git init operations when no explicit
branch name is configured
This follows the precedent set when init.defaultBranch configuration was
introduced in Git 2.28, which already acknowledged the community's move
toward more inclusive default branch names.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1961%2Fhuangsen365%2Fmaster-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1961/huangsen365/master-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1961
refs.c | 2 +-
remote.c | 2 +-
t/test-lib.sh | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/refs.c b/refs.c
index 4ff55cf24f6..929e9ce60c6 100644
--- a/refs.c
+++ b/refs.c
@@ -653,7 +653,7 @@ char *repo_default_branch_name(struct repository *r, int quiet)
die(_("could not retrieve `%s`"), config_display_key);
if (!ret) {
- ret = xstrdup("master");
+ ret = xstrdup("main");
if (!quiet)
advise_if_enabled(ADVICE_DEFAULT_BRANCH_NAME,
_(default_branch_name_advice), ret);
diff --git a/remote.c b/remote.c
index 81d8fc017e1..ffc4089a1c2 100644
--- a/remote.c
+++ b/remote.c
@@ -2379,7 +2379,7 @@ struct ref *guess_remote_head(const struct ref *head,
return copy_ref(r);
/* Fall back to the hard-coded historical default */
- r = find_ref_by_name(refs, "refs/heads/master");
+ r = find_ref_by_name(refs, "refs/heads/main");
if (r && oideq(&r->old_oid, &head->old_oid))
return copy_ref(r);
}
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 621cd31ae1d..4e273a6e94d 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -129,7 +129,7 @@ fi
# Explicitly set the default branch name for testing, to avoid the
# transitory "git init" warning under --verbose.
-: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master}
+: ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=main}
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
################################################################
base-commit: 1fa68948c3d76328236cac73d2adf33c905bd8e3
--
gitgitgadget
next reply other threads:[~2025-08-26 4:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 4:52 Wing Huang via GitGitGadget [this message]
2025-08-26 9:14 ` [PATCH] rename default branch from 'master' to 'main' in refs and test scripts Andreas Schwab
2025-08-26 9:58 ` Phillip Wood
2025-08-26 11:12 ` Jeff King
2025-08-27 13:26 ` Phillip Wood
2025-08-26 11:20 ` Phillip Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.1961.git.1756183921623.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=huangsen365@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).