In my gitlab CI I always get this hint messages. Yes, I see I have to set git config --global init.defaultBranch main, but everything I'm adding in my stages / jobs of the CI gitlab config is executed after fetching.
test:
stage: test
image:
name: registry.domain.com/project/ci:1.0.0
before_script:
- git config --global init.defaultBranch main
script:
- echo "something"
As I said, this is not working. At the moment of fetching, the before_script is not executed.
Using Kubernetes namespace: gitlab
Using Kubernetes executor with image
registry.domain.com/project/ci:1.0.0 ...
Using attach strategy to execute scripts...
...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
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 /builds/Cf_z92LS/0/project/repo/.git/
Created fresh repository.
Update
My custom docker image, which is used for the CI pipeline is created like this:
FROM alpine:3.14.2
RUN apk --update add bash curl git
RUN git config --global init.defaultBranch main
But I still get these message.
Running git config --list in the CI shows me, that the config value is set correctly:
init.defaultbranch=main
fetch.recursesubmodules=false
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true