You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已配置SSH Key仍执行pub get失败的Git仓库访问问题

解决pub get时Git仓库找不到的问题

问题说明

在IntelliJ IDE克隆项目后首次执行pub get,触发Git错误,具体命令及报错信息如下:

Git error. Command: `git clone --mirror git@github.com:open-runtime/aot_monorepo.git /Users/tarun/.pub-cache/git/cache/aot_monorepo-7a0b3d0f0477d2766d0540e8a0101f937bb7f0bf`
stdout: 
stderr: Cloning into bare repository '/Users/tarun/.pub-cache/git/cache/aot_monorepo-7a0b3d0f0477d2766d0540e8a0101f937bb7f0bf'...
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
exit code: 128

已通过ssh -T git@github.com确认SSH身份验证正常,同一组织下其他仓库曾通过验证SSH Key解决类似问题,但本次另一仓库仍触发该错误。

排查与解决步骤

1. 手动验证仓库访问权限

在终端直接执行克隆命令,确认是否能正常拉取:

git clone --mirror git@github.com:open-runtime/aot_monorepo.git

如果同样报错,联系组织仓库管理员确认:

  • 仓库open-runtime/aot_monorepo是否存在(未被删除或重命名)
  • 你的GitHub账号是否被授予该仓库的读取权限

2. 检查SSH配置冲突

查看~/.ssh/config文件,确认是否存在针对github.com的配置冲突(比如指定了错误的密钥文件):

cat ~/.ssh/config

若存在多GitHub账号配置,可添加针对该组织的专属配置:

Host github.com-open-runtime
  HostName github.com
  User git
  IdentityFile ~/.ssh/你的组织专用密钥文件名

之后将项目依赖中的仓库地址替换为github.com-open-runtime:open-runtime/aot_monorepo.git,或直接修改pubspec.yaml中的依赖源。

3. 清除Pub缓存后重试

删除Pub缓存中对应仓库的缓存目录:

rm -rf /Users/tarun/.pub-cache/git/cache/aot_monorepo-7a0b3d0f0477d2766d0540e8a0101f937bb7f0bf

重新执行pub get,或在IntelliJ中点击"Pub Get"按钮。

4. 统一IntelliJ与终端的Git环境

确认IntelliJ使用的Git路径和终端一致:

  1. 打开IntelliJ的Preferences(Mac系统)
  2. 导航到Version Control > Git
  3. 检查Path to Git executable是否与终端执行which git的输出一致
    若路径不同,修改为终端使用的Git路径,重启IntelliJ后重试。

5. 确认SSH密钥的组织权限

登录GitHub账号,进入Settings > SSH and GPG keys:

  • 确认当前使用的SSH密钥已获得open-runtime组织的访问权限
  • 若为个人密钥,需联系组织管理员将你加入对应团队或直接授予仓库权限

内容的提问来源于stack exchange,提问作者Tarun Kumar S

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 05:07:32