Cloning a private Github repo

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.


This worked for me:

git clone https://[email protected]/username/repo_name


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)