github clone private repo

Viewed 2971

I'm using a different computer and I'm trying to clone one of my repos, but when I clone a repo, github prompts me to enter my credentials and I fail to authenticate:

Username for 'https://github.com':
Password for 'https://myusername@github.com:

remote: Invalid username or password.
fatal: Authentication failed for "my github repo url link"

I don't have a github.com email for my account, so I am confused what credentials it is looking for. I have already setup my git config like this:

git config user.name = "my username"
git config user.email = "my gmail"
git config user.password = "my password"

edit

From the points mentioned below, I must now use my personal access token as my password, what is the best way to cache my personal access token so I don't have to keep entering it when I clone,push,etc ?

2 Answers

The git config user.xxx part is only for commit authorship, and has nothing to do with remote hosting service authentication.

You need to enter your GitHub user account name and token (PAT -- Personal Access Token -- that you need to generate).
This is safer than entering your GitHub account password, not to mention that, if you have 2FA activated, the password would not work anyway.

Activate a credential cache in order to not have to renter it every time.

A cross-platform one is manager-core:

git config --global credential.helper manager-core

Your three written commands have nothing to do with the git-credentials. Git commit use this informations, and it’s immutably baked into the commits you start creating.

And you don't have to have a GitHub email for this. You simple use your email, where you have register on GitHub and where you every time use to login in GitHub. In your case, you can display your email with git config user.email (provided the correct email address is stored there).

If you want to store the git credentials, you can do that with

git config --global credential.helper store

But be careful, this method saves the credentials in plaintext on your PC's disk. Everyone on your computer can access it.

More about credentials you can read here (Git - Credential Storage) or in many other articles on the internet.

Related