Skip to content

Conversation

jsoref
Copy link
Contributor

@jsoref jsoref commented Mar 24, 2021

Fixes #427

Suppress noise about that git itself is changing its default branch. When actions/checkout is used, it will always be given a specific branch (or similar) to check things out, and thus the default branch is not used...

Run actions/checkout@v2.0.0
Run actions/checkout@v2.0.0
  with:
    fetch-depth: 2
    repository: org/repo
    token: ***
    persist-credentials: true
    clean: true
    lfs: false
Syncing repository: org/repo
Working directory is '/home/runner/work/org/repo'
/usr/bin/git version
git version 2.30.0
Deleting the contents of '/home/runner/work/org/repo'
/usr/bin/git init /home/runner/work/org/repo
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint: 	git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint: 	git branch -m <name>
Initialized empty Git repository in /home/runner/work/org/repo/.git/

See #465 (comment) for a proof.

@jsoref
Copy link
Contributor Author

jsoref commented Apr 7, 2021

@ericsciple: is there something I need to do to get this considered?

@jsoref
Copy link
Contributor Author

jsoref commented Apr 18, 2021

@thboop @dscho: is there something I need to do to move this forward?

Copy link
Contributor

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer a shorter name, and I would have much preferred a proper analysis why this change is safe (instead, I was forced to perform that analysis myself, from scratch, and I imagine that this is the problem that prevents the team from merging this PR: it just asks for too much effort on the reviewers' side).

Having said that, I would not mind this PR being merged as-is, I would merely prefer above-mentioned issues to be addressed.

@jsoref
Copy link
Contributor Author

jsoref commented Jun 24, 2021

@hross what do I need to do to move this forward?

@dscho
Copy link
Contributor

dscho commented Jun 29, 2021

@ericsciple @TingluoHuang ping?

@jsoref
Copy link
Contributor Author

jsoref commented Jan 12, 2023

@vanZeben is there something that can be done to move this along?

@kbrock
Copy link

kbrock commented Jun 6, 2023

Looks like this stalled.

Are there other suggestions on silencing this warning? It shows up quite a few times.

@jsoref
Copy link
Contributor Author

jsoref commented Jun 7, 2023

@kbrock: I can rebase and you can use my fork that has the fix. Otherwise, you could technically create an action / wrapper /step that does:

git config --global init.defaultBranch silence_warning_about_default_branch

@jsoref jsoref requested a review from a team as a code owner June 7, 2023 15:30
@MestreLion
Copy link

My opinions on this:

  • The long form --initial-branch was a great choice. It's self-descriptive, and would have little to no point saving a few bytes with -b
  • The chosen branch name is only temporary and not referenced anywhere. It couldn't be otherwise, as the current master used by default is not hardcoded anywhere in this tool, and even when it doesn't match the cloned repo's this tool works on them just fine.
  • So, how about dummy? It's short, it clearly states it is temporary and irrelevant, and it avoids taking sides about master/main.

And remember that just like @dscho I'm not a maintainer (and not even a contributor), just a developer very interested in this PR going forward and eventually being accepted. It's been more than an year guys!

(PS: @jsoref , you might mark your conversation with @dscho as resolved, it would be one less red status on the pending items summary, this might incentivize a reviewer . And maybe ping an actual (human) maintainer/reviewer, as that CODEOWNERS file you used to ping the team seems to have errors (@actions/actions-runtime is not an actual team), so no one was actually pinged.)

@jsoref
Copy link
Contributor Author

jsoref commented Nov 28, 2024

@mouismail?

I'm happy to pick any name that a codeowner suggests.

Personally I use placeholder for my default branches (it doesn't have any negative connotations), but I don't want people to think that I'm actively favoring that here or that my use of placeholder would relate to the use here...

Anyway, I'm more than happy to update this (or any of my other PRs) although I'm about to be relatively unavailable for a bit.

@MestreLion
Copy link

Anyway, I'm more than happy to update this (or any of my other PRs) although I'm about to be relatively unavailable for a bit.

I suggest you preemptively change the branch name now to something shorter, such as your placeholder (a good choice!), or dummy, main or even master (current implicit default), just to avoid a situation where a reviewer asks for a change and this PR blocks again because you're unavailable. I believe the shorter names above will make it more likely for this PR to be accepted and merged without changes even if you're AFK.

@willrowe
Copy link

Git now includes this at the end of the message:

hint: Disable this message with "git config set advice.defaultBranchName false"

It seems that setting that config value would accomplish suppressing the message in the most direct way.

@jsoref
Copy link
Contributor Author

jsoref commented Jul 30, 2025

No.

https://github.com/git/git/blame/v2.50.0/t/t0001-init.sh#L833-L837 requires v2.50.0 and many runners don't have that.

Debian 12.8 has git version 2.39.5

@jsoref
Copy link
Contributor Author

jsoref commented Jul 30, 2025

Again, it's really pointless for me to do anything to a PR to any github owned repo until a GitHub staffer shows up and says "hey, I'm willing to talk to you about this."

This repository appears to be mostly abandoned.

@TingluoHuang is welcome to prove me wrong.

@willrowe
Copy link

@jsoref the config value can be set regardless of whether the installed version supports it or not. It would then help with newer versions going forward. I suggested this as an alternative that would not require any bikeshedding over the default branch name.

@jsoref
Copy link
Contributor Author

jsoref commented Jul 30, 2025

That's totally useless. And there's no point in bikeshedding. This PR works for any version of git that has the warning. It's only useful to bikeshed if there's a living maintainer. And there aren't.

root@0db61f84061c:/tmp/tmp.1sO90FTg4c# git version
git version 2.39.5
root@0db61f84061c:/tmp/tmp.1sO90FTg4c# git -c advice.defaultBranchName=false init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: 	git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: 	git branch -m <name>
Initialized empty Git repository in /tmp/tmp.1sO90FTg4c/.git/

@dscho
Copy link
Contributor

dscho commented Jul 31, 2025

@jsoref using an absurdly long branch name can run into "long path" problems on Windows, especially with recursive clones.

If I were a maintainer and saw the resistance against implementing obvious improvements, even if I had the time to engage I probably wouldn't unless someone forced me to.

@MestreLion
Copy link

If I were a maintainer and saw the resistance against implementing obvious improvements, even if I had the time to engage I probably wouldn't unless someone forced me to.

What resistance? Most (if not all) comments approved the PR. Any maintainer can just ignore the bikeshedding about the branch name, as many (including myself and the author) said any name is fine and should not be a blocker.

@dscho
Copy link
Contributor

dscho commented Aug 2, 2025

and should not be a blocker.

Well, I have told you that this long name is a blocker, as it can cause issues with long paths on Windows when cloning recursively.

And as I have said before, if I were a maintainer, I wouldn't appreciate it if any contributor simply tried to ignore away a valid concern like this.

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suppress hint: Using 'master' as the name for the initial branch. This default branch name
7 participants