-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CI: Set git default branch to "main" in CircleCI. #18572
Conversation
84d965b
to
555f452
Compare
OK, I noticed that locally |
@@ -45,7 +45,6 @@ def run(cmd, stdout=True): | |||
os.chdir(workdir) | |||
|
|||
run(['git', 'init']) | |||
run(['git', 'branch', '-m', 'master', 'main']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git checkout -b main
seems to work after the init.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we try that first? I am surprised that the "initial" branch would not be named master
though, so I was wondering if the git
version mismatch means that renaming branches doesn't really work at all at that time (mainly because at that time my git has git branch
show nothing). Do you have an older git version to confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have an older git version to confirm?
No, I have git version 2.29.2 and git init -b main
also worked for me, but without the specification there were no branches at all. Creating the branch by checking out should be pretty definite. Oddly, a simple git branch main
fails for lack of a master branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, I misread. git checkout -b main
sounds good, let me do that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets try that. Changed it (and mofidied the comment a bit).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since git version 2.28.0 the git init command now takes a --initial-branch (or -b for short) parameter.
So that isn't an option, but the checkout way seems valid, see https://tinyurl.com/y7v7brcl.
Should fix the current failure that "master" does not exist. I am a bit curious why master does not exist, maybe the CircleCI git is set up to use some other default. Move the branch rename to after the commit, to make sure that the fact that the branch is empty (and `git branch` also) cannot influence the result. [ci-skip]
And away we go. Thanks Sebastian. |
It works! |
git branch -m main
Should fix the current failure that "master" does not exist.
I am a bit curious why master does not exist, maybe the CircleCI
git is set up to use some other default?
I am starting to get confused, I just hope the branch name was actually at the core of the issue :) (although the error message does indicate so).