简体   繁体   中英

Git clone fails for private repository using Terminal

I am trying to clone a private repository using the Terminal, but it fails stating the following errors:

  1. The repository does not exist.
  2. Failure connecting with credentials.

I can successfully clone the same repo using xCode & Source Tree. I've added & verified SSH key & tried HTTP & SSH but the clone fails in both cases.

What am I missing here?

After many attempts I've found the solution. When you have to clone a private directory, git clone command changes a bit. Usually what we do is

git clone https://github.com/zzzubair/TestGit.git

which is fine if TestGit is public repository. But for private repository you've to mention your user name, which has right access to clone the repository, so this command changes to this.

git clone https://zzzubair@github.com/zzzubair/TestGit.git

I hope this'll help many others who are or will face the issue.

If you're using github and windows, verify that you generate your personal access tokens ( more info here ) and select the "repo" option (Full control of private repositories). Else, your token will be useful for public repositories.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM