Why can't I clone a private repository via GIT?

Viewed 1656

enter image description here

I added SSH key already successfully in GitHub. I have no idea why I kept getting this error when tried to clone a private repo.

SSH

➜  test git clone git@github.com:nike/consumer.git
Cloning into 'consumer'...
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

HTTPS

➜  test git clone https://github.com/nike/consumer.git
Cloning into 'consumer'...
remote: Repository not found.
fatal: repository 'https://github.com/nike/consumer.git/' not found

GitHub Desktop

success clone, fetch, commit and push enter image description here

Why ? Did I miss anything else ?


Connection confirmed

➜  test ssh -T git@github.com
Hi ${myname}! You've successfully authenticated, but GitHub does not provide shell access.
2 Answers

Yes, I have access to it from the website, and I copied and pasted the actual URL from the cloning section only

URL

Then the URL to clone would be

git@github.com:vi3global/consumer-engagement
# or
https://github.com/vi3global/consumer-engagement

Assuming that your account was added as a collaborator, since it is a private repository.

The URL would not be git@github.com:*nike*.

I had the same issue and spent a few hours debugging this. I don't know the specific reason as to why this works but I ended up restarting the SSH service:

System Preferences -> Sharing. 

Check and Un-check the Remote Login service. 

This restarts the SSH agent and i was able to successfully clone the private repo with a custom ssh configuration.

Related