Github Organization "remote: Repository not found." via Https Clone
Asked Answered
J

4

13

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?

Joanniejoao answered 17/3, 2018 at 22:6 Comment(7)
Is the repo empty? I recall having issues trying to clone empty repos in the past, but it's admittedly been a while.Morales
No it's not empty because I initialized it with a readme and a .gitignore.Joanniejoao
Are you sure you copy/pasted the remote correctly? Just for kicks, have you tried checking via ssh?Morales
OK, so cloning did work using SSH. However SSH is a pain and I would still like to understand what it is that's not working with https. The https cloning url is copied directly to the clipboard so I don't see how it could be incorrect.Joanniejoao
Let's go deeper down the rabbit hole :). Can you change the remote of origin in your fresh clone and do a git fetch? I've never dealt with private repos over https, so just trying to poke at things right now.Morales
ok so i ran git remote set-url origin https://github.com/my-organization/my-repo.git then git fetch and got fatal: repository 'https://github.com/my-organization/my-repo.git/' not foundJoanniejoao
The only other possibly relevant info is that the billing email address I entered for my organization is different from my regular github login email address. Seems like this should not be the issue though.Joanniejoao
J
13

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.

Joanniejoao answered 18/3, 2018 at 16:31 Comment(2)
You saved my day. I moved a repo to an organization I was owner of, but I was unable to push to it after updating the origin URL using set-url. What I did was pulling the repo again using git clone https://[email protected]/..., it prompted for a password and succeeded. I canceled the pulling, removed other credentials entries in the keychain (except for the new login one) and I was finally able to push with SourceTree, again. Thanks!Leaper
For linux users, you can delete cached ssh credentials with ssh-add -DPavis
S
3

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.

Scalene answered 30/5, 2020 at 12:13 Comment(0)
A
0

My suspects

  • you probably have and extra layer of security in your Private repo, confirm that you either don't have a two-way authentication or something else. That will make hit flag you and error or wrong login credentials anytime you try to push.

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.

Amu answered 18/3, 2018 at 1:32 Comment(0)
G
0

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])
Gemagemara answered 6/8 at 2:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.