To clone a private repository from your account or organization, you need to generate a PAT(Personal Access Token) on your Github account, and add it to the command above. *Organization doesn't have PAT generator.
You also have the option to clone a private GitHub repository using SSH. To do this, you need to start by generating an SSH keypair on your local device. Then add a public key to your GitHub account. This gives you the ability to connect your local device with GibHub using a secure channel over an unsecured network.
This worked for me:
git clone https://[email protected]/username/repo_name
Private clone URLs take the form [email protected]:username/repo.git
- perhaps you needed to use git@
rather than git://
?
git://
URLs are read only, and it looks like private repos do not allow this form of access.
I have met this issue several times and every time I landed on this page, tried every thing and failed!
It's because I have 2FA enabled!!!
According to https://help.github.com/articles/which-remote-url-should-i-use/#when-2fa-is-enabled
If you have enabled two-factor authentication, or if you are accessing an organization that uses SAML single sign-on, you must provide a personal access token instead of entering your password for HTTPS Git.
git clone https://github.com/username/repo_name.git
(The default git repo link is good enough!)Update:
git config credential.helper store
(don't do this on machine you don't trust)This worked for me:
git clone https://username:[email protected]/username/repo_name.git
For me the solution was:
git clone https://[email protected]
Here you need to be the owner of the repo but if you aren't then it will go as
git clone https://[email protected]/ownersusername/repo_name.git
If you have 2FA enabled
then:
git clone https://[email protected]
When prompted for password put that token in here.
Using Git for Windows it is easier to use HTTPS url.
Open a git shell then git clone https://github.com/user/repo
. Enter username and password when prompted. No need to setup a SSH key.
As everyone aware about the process of cloning, I would like to add few more things here. Don't worry about special character or writing "@" as "%40" see character encoding
$ git clone https://username:[email protected]/user/repo
This line can do the job
To solve this issue I encourage to use GitHub Developer option to generate Access token. I believe Access token is secure and you wont find any special character.
creating-a-personal-access-token
Now I will write the below code to access my repository.
$ git clone https://username:[email protected]/user/repo
I am just replacing my original password with Access-token, Now I am not worried if some one see my access credential , I can regenerate the token when ever I feel.
Make sure you have checked repo Full control of private repositories
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