I am using git 2.19.0 and I have my release CI job failing.
I want to authenticate using git git-credentials.
This is how I create my $HOME/.config/git/credentials
if [[ "${CI_PROJECT_URL}" =~ (([^/]*/){3}) ]]; then
mkdir -p $HOME/.config/git
echo "${BASH_REMATCH[1]/:\/\//://gitlab-ci-token:${GL_TOKEN:-$GITLAB_TOKEN}@}" > $HOME/.config/git/credentials
git config --global credential.helper store
fi
This is what I have in .git/config
:
[fetch]
recurseSubmodules = false
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@git.example.com/some-org/some-project.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
This is what I have in $HOME/.config/git/credentials
:
$ cat $HOME/.config/git/credentials
https://gitlab-ci-token:Dwq456WQd4q56QW@git.example.com/
However, when I do git push
, it fails to use that configuration, instead it read the one from .git/config
within the project.
Doing cp $HOME/.config/git/credentials ~/.git-credentials
did not help.
Why would a $HOME/.config/git/credentials would be ignored when I do git push
?