Reputation: 2265
I have been using Github as an individual for some time. Now I need to create an organization and start a repo in the organization.
So, logged in to Github as myself, I created the new organization. I then created a repo. Viewing the repo I can see that I am a contributor to the repo. The repo is, and needs to be, private.
When I try to clone:
$ git clone https://github.com/my-organization/my-repo.git my-repo-folder
Cloning into 'my-repo-folder'...
remote: Repository not found.
fatal: repository 'https://github.com/my-organization/my-repo.git/' not found
Locally git is remembering my credentials, so for example, if I have a repository in my personal Github repos, which is private, then
git clone https://github.com/Webern/my-personal-private-repo.git
works without requesting that I re-enter my Github username and password.
What is going on with the organization? How do I clone my newly-formed organizations private repo?
Upvotes: 13
Views: 13140
Reputation: 6179
Faced this issue on OSX 14.6 and managed to solve it by removing all the credentials from the agent and re-adding them back again afterwards (besides removing keychain's keys as mentioned above):
➜ urbancompass git:(master) ssh-add -D
All identities removed.
➜ urbancompass git:(master) ssh-add ~/.ssh/id_ed25519
Identity added: /Users/jonathan.scherman/.ssh/id_ed25519 ([email protected])
Upvotes: 0
Reputation: 181
In case you have access tokens enabled for your GitHub account, make sure to tick the entire repo
setting under Developer settings -> Personal access tokens as shown here (Step 7). Enabling all suboptions in the repo
category is not enough.
That did the trick for me. No need to reset your credentials anywhere.
I had only the public_repo
option enabled and that was sufficient to clone and push to my public repos but not to private repos in the organization where I even had an admin role.
The error is quite cryptic and misleading, especially when you are sure to have all the access rights.
Upvotes: 4
Reputation: 2265
Ultimately I believe the problem had something to do with the caching of credentials in my Mac's Keychain. The complete list of steps taken to fix the problem is below, but I believe the crucial step was to delete all Github credentials using Mac OS's Keychain Access utility.
Adding the username and password to the https URL does work, but seems like a bad idea for permanent use.
MyMac:~ mjb$ git clone https://MyGithubUsername:[email protected]/my-organization/my-repo.git
MyMac:~ mjb$ cd my-repo
MyMac:my-repo mjb$ git remote set-url origin https://github.com/my-organization/my-repo.git
After changing the URL back so that it does not contain my username and password, I still could not connect to the remote.
MyMac:my-repo mjb$ git push origin --all
remote: Repository not found.
Now I did a bunch of flailing with git config, which I suppose was unnecessary.
MyMac:my-repo mjb$ git config --global user.name MyGithubUsername
MyMac:my-repo mjb$ git --version
git version 2.15.0
MyMac:my-repo mjb$ git config --global credential.helper manager
MyMac:my-repo mjb$ git push origin --all
remote: Repository not found.
fatal: repository 'https://github.com/my-organization/my-repo.git/' not found
MyMac:my-repo mjb$ git config --global --unset credential.helper
MyMac:my-repo mjb$ git push origin --all
remote: Repository not found.
fatal: repository 'https://github.com/my-organization/my-repo.git/' not found
Now I went on my Mac to Utilities -> Keychain Access
I deleted all credentials relating to Github
What is strange about this is that they were correct, and when I entered my username and password again I was entering the same username and password.
MyMac:my-repo mjb$ git push origin --all
Username for 'https://github.com': MyGithubUsername
Password for 'https://[email protected]': MyGithubPassword
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 651 bytes | 651.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
Success.
Upvotes: 13
Reputation: 9923
My suspects
But in your case, you were trying to clone, so ensure that you're using the same credentials(email most especially) that you're using in the organization repo and your personal repo, it might possible be a permission thing. Git might assume the credentials you entered doesn't have the right to access the repo.
Upvotes: 0