git - Clone A Private Repository (Github)

ID : 10321

viewed : 45

Tags : gitauthenticationgithubgit-cloneprivate-repositorygit

Top 5 Answer for git - Clone A Private Repository (Github)

vote vote

98

This worked for me:

git clone https://username@github.com/username/repo_name

vote vote

86

Private clone URLs take the form git@github.com: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.

vote vote

73

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.

  1. Follow this link and create an access token
  2. git clone https://github.com/username/repo_name.git (The default git repo link is good enough!)
  3. Enter your username and use the access token as password!!

Update:

  • If you don't mind exposing your access token in the command line, you can also paste the access token as username then hit enter enter (no need for password).
  • Hate copy&pasting the access token over and over again?
    Use git config credential.helper store (don't do this on machine you don't trust)
vote vote

61

This worked for me:

git clone https://username:password@github.com/username/repo_name.git 
vote vote

57

For me the solution was:

git clone https://myusername@restoftherepolink.git 

Here you need to be the owner of the repo but if you aren't then it will go as

git clone https://myusername@github.com/ownersusername/repo_name.git 

If you have 2FA enabled then:

  1. Go to the settings from the profile icon in top right or visit https://github.com/settings/profile
  2. Go to the bottom tab or go to https://github.com/settings/tokens
  3. Open last tab here Personal tokens. And generate a token
  4. Copy the token and run git clone https://myusername@restoftherepolink.git

When prompted for password put that token in here. Token generation image here

Top 3 video Explaining git - Clone A Private Repository (Github)

Related QUESTION?