One way to clone a repository without having to enter your password would be to create an app-password and use it while cloning. That done, git won't prompt for user name and password. Mind that this is a URL and needs to be encoded as an URL then. This will leave the password in the git configuration.
Find out how to fix this here:
https://github.com/blog/1614-two-factor-authentication#how-does-it-work-for-command-line-git
How does it work for command-line Git?
If you are using SSH for Git authentication, rest easy: you don't need to do anything. If you are using HTTPS Git, instead of entering your password, enter a personal access token. These can be created by going to your personal access tokens page.
As per @Nitsew's answer, Create your personal access token and use your token as your username and enter with blank password.
Later you won't need any credentials to access all your private repo(s).
Updates 2021: (It worked for my M1 Mac)
Create new Personal Access Tokens (Tick the appropriate boxes to grant permissions).
Use GitHub username
and password as your Personal Access Tokens
To everyone struggling, what worked for me was creating personal access token and then using it as a username AND password (in the prompt that opened).
It generally comes to mind that you have set up two-factor authentication, after a few password trials and maybe a password reset. So, how can we git clone a private repository using two-factor authentication? It is simple, using access tokens.
How to Authenticate Git using Access Tokens
Wow, it works!
1st: Get personal access token. https://github.com/settings/tokens
2nd: Put account & the token. Example is here:
$ git push
Username for 'https://github.com': # Put your GitHub account name
Password for 'https://{USERNAME}@github.com': # Put your Personal access token
Link on how to create a personal access token: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With