我将我的 ssh 密钥放在 github 中,因此git clone
适用于某个私有存储库;go mod tidy
尝试访问同一存储库时失败,错误消息如下所示。我可以使用帮助解决此问题。go mod tidy
来自(编辑私有存储库的名称,但逐字逐句)的错误消息是:
github.com/[private repository path]: cannot find module providing package github.com/[private repository path]: module github.com/[private repository path]: git ls-remote -q origin in /mnt/dependencies/gopath/pkg/mod/cache/vcs/a1f499df6a9855aecdc77bda31504008583a3268fdd403799aade71bb47df7d2: exit status 128:
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository
Please make sure you have the correct access rights
and the repository exists.
成功的 git clone 命令(再次编辑私有存储库)是:
git clone [email protected]:[private repository path].git
我的.gitconfig
文件是(我的姓名和电子邮件已编辑):
[user]
name = [my name]
email = [my email]
[url "github.com:"]
insteadOf = https://github.com/
[core]
excludesfile = /workdir/.gitignore
其他可能会产生影响的事情:
go mod tidy
相同的密钥在我的主机上运行~/.ssh
,我得到了登录提示,github 不再支持(他们需要 SSH 密钥或个人访问令牌)。第二个相关问题:我可以运行的事实是否git clone
排除了将密钥错误地上传到 github,而忘记为 github 上的密钥启用 SSO?
这是一个类似的问题,但它涉及个人访问令牌而不是 ssh 密钥:`go mod tidy` 无法下载私有 GitHub 存储库
我在 Docker 容器中以 root 身份运行命令。
确保它确实访问了/root/.ssh
与您在常规帐户中使用的相同的密钥(in )。
并检查 Git 全局配置设置是否真的包含您的insteadOf
指令。
~/.ssh
尝试使用与 Docker 容器上相同的密钥在我的主机上运行 go mod tidy,但我得到了登录提示。
这意味着公钥没有正确注册到 GitHub 用户配置文件,或者说用户无权访问存储库。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句