fatal: No url found for submodule path ‘xxx/xxx‘ in .gitmodules gitsubmodule子仓库无法拉取问题

fatal: No url found for submodule path ‘xxx/xxx’ in .gitmodules

错误现场还原:

  1. windows上add submodule
  2. mac上clone主体项目
  3. git submodule init时发生错误
  4. 查看.gitmodules内容如下
    [submodule ".\\xxx\\xxx"]
    	path = .\\xxx\\xxx
    	url = http://xxx.xxx.xxx.git
    

错误分析:

  1. url错误,仔细查验后确定无误
  2. path错误,window|mac路径反斜杠问题,修改为/后验证仍然报错
  3. submodule name问题,修正为不带路径名xxx后仍旧报错

重新复盘,综合思考:
fatal: No url found for submodule path ‘xxx/xxx’ in .gitmodules
报错中,/而不是\,没有./
回忆下执行git submodule add时有写./xxx/xxx,尝试修改.gitmodules

[submodule "xxx/xxx"]
	path = xxx/xxx
	url = http://xxx.xxx.xxx.git

重新执行命令:

git submodule init
# Submodule 'xxx/xxx' (http://xxxx/xxx/xxx.git) registered for path 'xxx/xxx'
git submodule sync
# Synchronizing submodule url for 'xxx/xxx'
git submodule update
#Cloning into '/Users/xxx/xxx/xxx'...
#Submodule path 'xxx/xxx': checked out '39cabde3d5c8aeba5623424asd7f5948e7f515f9f28db'

ok,解决

推测既然有path属性submodule name不包含路径也是可以的,尝试改为:

[submodule "xxx"]
	path = xxx/xxx
	url = http://xxx.xxx.xxx.git

结果可以正常init,sync

总结,
1.git submodule add [path] 路径中不要写./
2.windows上添加子模块后最好改把.gitmodule的路径反斜杠改下

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值