Ploppz
Ploppz

Reputation: 144

Git doesn't use credentials from git-credentials-store file

I'm trying to compile some Rust code inside CI, which depends on another private git repository. Since it's in CI I cannot enter credentials manually, so I'm trying to use git-credentials-store. This is what I did in my attempt to set up git-credentials-store:

echo 'https://username:[email protected]/repo.git' > git-credentials
git config credentials.helper 'store --file git-credentials'`

To build the project, it has to fetch from that private git repo. When it tries to build, it fails, saying that this is the command it tried:

git fetch --tags --force --update-head-ok 'https://placeholder.com/git/repo.git' 'refs/heads/*:refs/heads/*'

And this is the error message:

fatal: could not read Username for 'https://placeholder.com': No such device or address

Would this indicate that it asks for username in stdin? I expected that the command would use the username and password from the git-credentials file.

Upvotes: 0

Views: 2801

Answers (1)

bk2204
bk2204

Reputation: 76964

In general, the URL put in the credential file should not contain a path component. The git credential-store manual page gives this format:

https://user:[email protected]

Git doesn't usually consider the path component at all when looking up credentials unless credential.useHTTPPath is set. If you set a path component, you're likely not going to match what Git requests in this case, which is a generic set of credentials for the domain in question.

Upvotes: 1

Related Questions