From 6d89d0d423bd3117734ec07bbd610fa215d4874f Mon Sep 17 00:00:00 2001 From: Wing Huang Date: Tue, 26 Aug 2025 00:08:27 +0800 Subject: [PATCH] rename default branch from 'master' to 'main' in refs and test scripts Signed-off-by: Wing Huang modified: refs.c modified: remote.c modified: t/test-lib.sh --- 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 4ff55cf24f68ee..929e9ce60c64af 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 81d8fc017e1b37..ffc4089a1c2ef7 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 621cd31ae1dc51..4e273a6e94d725 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 ################################################################