我作为个人使用 Github 已经有一段时间了。现在我需要创建一个组织并在组织中启动一个 repo。
所以,以我自己的身份登录到 Github,我创建了新组织。然后我创建了一个 repo 。查看 repo 我可以看到我是 repo 的贡献者。 repo 是并且需要是私有(private)的。
当我尝试克隆时:
$ 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
本地 git 正在记住我的凭据,例如,如果我的个人 Github 存储库中有一个存储库,它是私有(private)的,那么
git clone https://github.com/Webern/my-personal-private-repo.git
无需要求我重新输入我的 Github 用户名和密码即可工作。组织怎么了?如何克隆我新成立的组织私有(private) repo ?
最佳答案
最终,我相信这个问题与我的 Mac 钥匙串(keychain)中的凭据缓存有关。解决问题的完整步骤列表如下,但我认为关键步骤是使用 Mac OS 的 Keychain Access 实用程序删除所有 Github 凭据。
将用户名和密码添加到 https URL 确实有效,但对于永久使用来说似乎是个坏主意。
MyMac:~ mjb$ git clone https://MyGithubUsername:MyGithubPassword@github.com/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
将 URL 改回来使其不包含我的用户名和密码后,我仍然无法连接到远程。
MyMac:my-repo mjb$ git push origin --all
remote: Repository not found.
现在我用 git config 做了一堆乱七八糟的事情,我认为这是不必要的。
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
现在我在我的 Mac 上转到 Utilities -> Keychain Access
我删除了与 Github 相关的所有凭据
奇怪的是它们是正确的,当我再次输入我的用户名和密码时,我输入了相同的用户名和密码。
MyMac:my-repo mjb$ git push origin --all
Username for 'https://github.com': MyGithubUsername
Password for 'https://MyGithubUsername@github.com': 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)
成功。
关于Github 组织 "remote: Repository not found."通过 HTTPS 克隆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49342356/