git坑——子模块

坑:

在一个文件夹下,git clone一个子模块,然后再把这个文件夹initadd .,会出现错误,执行过程如下:

cd try2
git clone git@192.168.10.30:Algorithm4/Programs/ADC/modules/ITP/aoi_info.git
git init 
git add .
#warning: 正在添加嵌入式 git 仓库:aoi_info
#提示:You have added another git repository inside your current repository.
#提示:Clones of the outer repository will not contain the contents of
#提示:the embedded repository and will not know how to obtain it.
#提示:If you meant to add a submodule, use:
#提示:
#提示:	git submodule add <url> aoi_info
#提示:
#提示:If you added this path by mistake, you can remove it from the
#提示:index with:
#提示:
#提示:	git rm --cached aoi_info
#提示:
#提示:See "git help submodule" for more information.

解法:

以后避免这种情况,可以先将母文件夹git init了,然后git submodule add [url]即可,那么addcommitpush都没有问题了。

值得注意的是,如果将这种存储库push到云端,然后再pull或者clone回来,那么会发现aoi_info子模块内容为空,这是因为repoA下嵌入了一个repoB,所以需要执行git submodule update --init --recursive把子仓库内容拉过来。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值