Git clone always asks for Personal Access Token (private repo)
Solution 1
You can use the git credentials storage for storing your username and passwords while accessing the repository over https.
Run
git config credential.helper store
and then
git pull
This will ask your username and passwords and then remember it for future use. Please note running above commands will create a file at ~/.git-credentials
and store the credentials in plain text which can be a security risk.
An alternative is to store the credentials in memory rather than the disk. To do this you can run the below command.
git config credential.helper 'cache --timeout=3600'
This way git will not any files on disk and use the memory for storing the credentials. the timeout
argument here is used to specify that the credentials should be cached for next 1 hour.
Solution 2
You can clone using SSH, and authenticate using your SSH key. There is a nice guide from GitHub on how to set up git with SSH, and it works very similarly for other providers. After you set it up, don't forget to clone the repo using the SSH URL (not the HTTPS one), or to change the origin
of your cloned repo to the SSH URL.
Anevo
Updated on July 22, 2022Comments
-
Anevo almost 2 years
Every time I'm trying to clone a private repo I get the prompt to add my username and password.
I looked around to see what's wrong, because I added my password and didn't work, and found out that I have to use the Personal Access Token. Now every time I'm trying to clone a private repo I have to add that (or generate another) token.
Is there a way to clone a private git repo without the token? Or at least to be able to add my password instead of that token?