gpt4 book ai didi

git - 当 git clone 工作时,Go mod tidy 在私有(private)存储库上失败

转载 作者:行者123 更新时间:2023-12-05 01:23:20 27 4
gpt4 key购买 nike

我将我的 ssh key 放在 github 中,这样 git clone 就可以用于某个私有(private)存储库;然而 go mod tidy 在尝试访问同一个存储库时失败,错误消息如下所示。我可以使用帮助来解决这个问题。来自 go mod tidy 的错误消息(编辑私有(private)存储库的名称,但除此之外一字不差)是:

    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 命令(再次编辑私有(private)存储库)是:

git clone git@github.com:[private repository path].git

我的 .gitconfig 文件是(删除了我的名字和电子邮件):

[user]
name = [my name]
email = [my email]
[url "github.com:"]
insteadOf = https://github.com/
[core]
excludesfile = /workdir/.gitignore

其他可能产生影响的事情:

  • 我在 Docker 容器中以 root 身份运行命令。
  • 我尝试在我的主机上运行 go mod tidy,在 ~/.ssh 中使用与我在 Docker 容器中相同的 key ,我得到了登录提示, github 不再支持(他们需要 SSH key 或个人访问 token )。
  • 我的 gitconfig 中的电子邮件与我放在 github.com 上的公钥中给出的电子邮件匹配。

第二个相关问题:我可以运行 git clone 的事实是否排除了错误上传到 github 的 key ,以及忘记为 github 上的 key 启用 SSO?

这是一个类似的问题,但它涉及个人访问 token 而不是 ssh key :`go mod tidy` fails to download private GitHub repository

最佳答案

I am running commands as root in a Docker container.

然后确保它访问的 key (在 /root/.ssh 中)与您在常规帐户中使用的 key 相同。

并检查 Git 全局配置设置是否实际包含您的 insteadOf 指令。

tried to run go mod tidy on my host with the same key in ~/.ssh as I have on the Docker container, and I got login prompts.

这意味着公钥未正确注册到 GitHub 用户配置文件,或者该用户无权访问存储库。

关于git - 当 git clone 工作时,Go mod tidy 在私有(private)存储库上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72581998/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com