玩转GIT系列之【git submodule update出错提示子模组未对路径注册】

今天在github上找到了一个很有意思的项目,叫做listen1【https://github.com/listen1】,它是一个开源的项目,可以从各大音乐网站自动化搜索歌曲、避免某个特定的网站因为版权问题而无法听歌,超级实用(这里先给作者点个赞,打个小广告)。下面摘自作者的原文:

当我发现找个想听的歌因为版权听不了,需要打开好几个网站开始搜索,来回切换让我抓狂的时候,我知道是时候该做点什么了。
妈妈再也不用担心我找不到我想听的歌了。这里包含了网易云音乐,虾米,QQ音乐, 酷狗音乐,酷我音乐的曲库,够全够大了吧。
搜歌,听歌,就用 Listen1。

于是尝试将它的源码clone下来学习学习。可是clone下来之后,看到一个提示信息,说:

项目中包含了listen1_chrome_extension的引用,在checkout后需要把引用库初始化
git submodule update --init --recursive

于是,执行。

可是,出错:

leon@Ubuntu:~/studytest/listen1_desktop$ git submodule update --init --recursive
子模组 'app/listen1_chrome_extension' (git@github.com:listen1/listen1_chrome_extension.git) 未对路径 'app/listen1_chrome_extension' 注册
正克隆到 'app/listen1_chrome_extension'...
The authenticity of host 'github.com (52.74.223.119)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,52.74.223.119' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: 无法克隆 'git@github.com:listen1/listen1_chrome_extension.git' 到子模组路径 'app/listen1_chrome_extension'

于是开始百度“git submodule”相关的各类博文,却始终没有发现一个对路的解决办法,大多数人都是拷贝、复制、黏贴、转发别人的博文,没有什么参考意义。

终于,历经千辛万苦(略有夸张哈哈),在一位大神的博客里找到了成功的解决方案:

因为我使用的git url格式与原项目下的.gitmodule文件中的url格式不对,它写的是git格式,而我使用的是https的格式

按照以下方法更换一下即可:

vi .gitmodules

将下面的原文:

[submodule "app/listen1_chrome_extension"]
    path = app/listen1_chrome_extension
    url = git@github.com:listen1/listen1_chrome_extension.git

修改成:

[submodule "app/listen1_chrome_extension"]
    path = app/listen1_chrome_extension
    url = https://github.com/listen1/listen1_chrome_extension.git

修改完后,再次执行:

leon@Ubuntu:~/studytest/listen1_desktop$ git submodule update --init --recursive
正克隆到 'app/listen1_chrome_extension'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: 无法克隆 'git@github.com:listen1/listen1_chrome_extension.git' 到子模组路径 'app/listen1_chrome_extension'

肿么还是出错!!!!????

淡定淡定,再来分析。原来是子模块的url没有同步修改,于是执行下面的命令:

leon@Ubuntu:~/studytest/listen1_desktop$ git submodule sync'app/listen1_chrome_extension' 同步子模组 url

最后再来:

leon@Ubuntu:~/studytest/listen1_desktop$ git submodule update --init --recursive
正克隆到 'app/listen1_chrome_extension'...
remote: Enumerating objects: 45, done.
remote: Counting objects: 100% (45/45), done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 899 (delta 20), reused 24 (delta 11), pack-reused 854
接收对象中: 100% (899/899), 1.00 MiB | 322.00 KiB/s, 完成.
处理 delta 中: 100% (587/587), 完成.
检查连接... 完成。
子模组路径 'app/listen1_chrome_extension':检出 '0af87e6b028a1ac2f544b74aca1824b2cef66880'

终于成功了!!!

  • 18
    点赞
  • 45
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
运行命令 "git submodule init && git submodule update" 出错的原因可能是由于无法访问模块所在的地址导致的。这种情况通常发生在模块的地址无法被克隆或访问的情况下。 为了解决这个问题,你可以尝试以下两种解决方案之一: 1. 使用镜像地址:你可以将模块的地址中的 "https://github.com" 替换为 "https://github.com.cnpmjs.org"。这是一个在国内提供的GitHub镜像地址,可以提高访问速度和稳定性。 2. 使用其他可访问的地址:如果镜像地址无法解决问题,你可以尝试寻找其他可访问的地址,例如在 Gitee 上找到别人 fork 的对应项目的地址。然后将模块的地址替换为这个可访问的地址。 通过以上两种解决方案之一,你应该能够成功运行命令 "git submodule init && git submodule update",并且成功克隆模块的代码。请注意,确保你有足够的网络连接,以便能够访问模块所在的地址。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [git submodule update --init 失败解决办法](https://blog.csdn.net/sunjindeng123/article/details/124246100)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值