Strange behavior using git config credential.helper 'store'
.
> git version
> git version 2.39.0
OS: Ubuntu 22.04.1 LTS
I saw a bunch of other questions but none of them seem to solve my issue.
> git clone <url>
> Username for '<url>': my-username
> Password for '<url>': <typed the password>
Ok, the repository was cloned.
> git config credential.helper 'store'
> git pull origin develop
> fatal: repository '<url>' not found
If I do
> git config credential.helper ''
And then pull right after
> git pull origin develop
Things work.
Everytime I set the credential.helper to store, I got the fatal: repository '<url>' not found
error.
Strange enough, it happened only in this repository. All other repositories in my machine are working.
What is happening?
CodePudding user response:
Ok, so here's the solution, I feel a bit dumb now.
Reading the docs for git config credential.helper 'store'
I found that git, by default, store credentials in the ~/.git-credentials
file.
This project is using AWS Code Commit. I already used Code Commit for other projects, then I already had credentials stored for these other projects. The problem resides in the fact that the current project uses Code Commit in the same AWS region, then it's base URL is the same as the previous project, but with one major difference: the account.
The base URL for Code Commit is https://git-codecommit.sa-east-1.amazonaws.com/ for both projects, but their account is different, resulting in a different username too.
Since I already had a username for the same URL stored in ~/.git-credentials
, then Git was not able to find the correct username and password for this repo, resulting in this strange error fatal: repository '<url>' not found
The solution: point the credential helper for this project to another, file as the docs clearly tell us how to do:
git config credential.helper "store --file=/path/to/my/new/credentials/file/credentials"