Zubair
Zubair

Reputation: 945

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?

Upvotes: 2

Views: 2328

Answers (2)

Zubair
Zubair

Reputation: 945

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://[email protected]/zzzubair/TestGit.git

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

Upvotes: 3

JACH
JACH

Reputation: 1048

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.

Upvotes: 0

Related Questions