Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git clone always asks for Personal Access Token (private repo)

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?

like image 309
Anevo Avatar asked Apr 02 '19 10:04

Anevo


People also ask

How do I fix Git always asking for credentials?

Entering Git Username and Password in Remote URL To prevent Git from asking for your username and password, you can enter the login credentials in the URL as shown. The main drawback of this method that your username and password will be saved in the command in the Shell history file.

Why is Git asking for username and password every time?

If Git prompts you for a username and password every time you try to interact with GitHub, you're probably using the HTTPS clone URL for your repository. Using an HTTPS remote URL has some advantages compared with using SSH.

How do I stop Git push from asking for username and password?

Issue the command git fetch/push/pull. You will not then be prompted for the password.


1 Answers

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.

like image 161
Manvendra Singh Avatar answered Oct 18 '22 02:10

Manvendra Singh