如何从GitHub克隆带有子模块的仓库,比如FreeRTOS

情形一:首次克隆

git clone --recurse-submodules git@github.com:FreeRTOS/FreeRTOS.git

该命令会递归克隆该仓库及所有的子模块。

工程目录下的.gitmodules文件内容如下:

[submodule "FreeRTOS/Source"]
    path = FreeRTOS/Source
    url = https://github.com/FreeRTOS/FreeRTOS-Kernel.git
[submodule "FreeRTOS/Test/CMock/CMock"]
    path = FreeRTOS/Test/CMock/CMock
    url = https://github.com/ThrowTheSwitch/CMock.git
[submodule "FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP"]
    path = FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP
    url = https://github.com/FreeRTOS/FreeRTOS-Plus-TCP
[submodule "FreeRTOS-Plus/Source/AWS/device-shadow"]
    path = FreeRTOS-Plus/Source/AWS/device-shadow
    url = https://github.com/aws/device-shadow-for-aws-iot-embedded-sdk
[submodule "FreeRTOS-Plus/Source/Application-Protocols/coreMQTT"]
    path = FreeRTOS-Plus/Source/Application-Protocols/coreMQTT
    url = https://github.com/FreeRTOS/coreMQTT
[submodule "FreeRTOS-Plus/Source/coreJSON"]
    path = FreeRTOS-Plus/Source/coreJSON
    url = https://github.com/FreeRTOS/coreJSON
[submodule "FreeRTOS-Plus/Test/CMock"]
    path = FreeRTOS-Plus/Test/CMock
    url = https://github.com/ThrowTheSwitch/CMock
[submodule "FreeRTOS-Plus/ThirdParty/mbedtls"]
    path = FreeRTOS-Plus/ThirdParty/mbedtls
    url = https://github.com/Mbed-TLS/mbedtls.git
[submodule "FreeRTOS-Plus/Source/Application-Protocols/corePKCS11"]
    path = FreeRTOS-Plus/Source/corePKCS11
    url = https://github.com/FreeRTOS/corePKCS11.git
[submodule "FreeRTOS-Plus/Source/AWS/jobs"]
    path = FreeRTOS-Plus/Source/AWS/jobs
    url = https://github.com/aws/jobs-for-aws-iot-embedded-sdk.git
[submodule "FreeRTOS-Plus/Source/AWS/device-defender"]
    path = FreeRTOS-Plus/Source/AWS/device-defender
    url = https://github.com/aws/device-defender-for-aws-iot-embedded-sdk.git
[submodule "FreeRTOS-Plus/Source/Application-Protocols/coreHTTP"]
    path = FreeRTOS-Plus/Source/Application-Protocols/coreHTTP
    url = https://github.com/FreeRTOS/coreHTTP
[submodule "FreeRTOS-Plus/Source/Utilities/backoff_algorithm"]
    path = FreeRTOS-Plus/Source/Utilities/backoff_algorithm
    url = https://github.com/FreeRTOS/backoffAlgorithm.git
[submodule "FreeRTOS-Plus/ThirdParty/wolfSSL"]
    path = FreeRTOS-Plus/ThirdParty/wolfSSL
    url = https://github.com/wolfSSL/wolfssl.git
[submodule "FreeRTOS-Plus/Source/Application-Protocols/coreMQTT-Agent"]
    path = FreeRTOS-Plus/Source/Application-Protocols/coreMQTT-Agent
    url = https://github.com/FreeRTOS/coreMQTT-Agent.git
[submodule "FreeRTOS-Plus/Source/AWS/ota"]
    path = FreeRTOS-Plus/Source/AWS/ota
    url = https://github.com/aws/ota-for-aws-iot-embedded-sdk.git
[submodule "FreeRTOS-Plus/Source/Application-Protocols/coreSNTP"]
    path = FreeRTOS-Plus/Source/Application-Protocols/coreSNTP
    url = https://github.com/FreeRTOS/coreSNTP.git
[submodule "FreeRTOS/Demo/ThirdParty/Community-Supported-Demos"]
    path = FreeRTOS/Demo/ThirdParty/Community-Supported-Demos
    url = https://github.com/FreeRTOS/FreeRTOS-Community-Supported-Demos
[submodule "FreeRTOS/Demo/ThirdParty/Partner-Supported-Demos"]
    path = FreeRTOS/Demo/ThirdParty/Partner-Supported-Demos
    url = https://github.com/FreeRTOS/FreeRTOS-Partner-Supported-Demos
[submodule "FreeRTOS-Plus/Source/AWS/sigv4"]
    path = FreeRTOS-Plus/Source/AWS/sigv4
    url = https://github.com/aws/SigV4-for-AWS-IoT-embedded-sdk.git
[submodule "FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface"]
    path = FreeRTOS-Plus/Source/FreeRTOS-Cellular-Interface
    url = https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface.git
[submodule "FreeRTOS-Plus/ThirdParty/tinycbor"]
    path = FreeRTOS-Plus/ThirdParty/tinycbor
    url = https://github.com/intel/tinycbor.git
[submodule "FreeRTOS-Plus/Source/AWS/fleet-provisioning"]
    path = FreeRTOS-Plus/Source/AWS/fleet-provisioning
    url = https://github.com/aws/Fleet-Provisioning-for-AWS-IoT-embedded-sdk.git
[submodule "FreeRTOS-Plus/Source/FreeRTOS-Cellular-Modules/bg96"]
    path = FreeRTOS-Plus/Source/FreeRTOS-Cellular-Modules/bg96
    url = https://github.com/FreeRTOS/Lab-FreeRTOS-Cellular-Interface-Reference-Quectel-BG96.git
[submodule "FreeRTOS-Plus/Source/FreeRTOS-Cellular-Modules/hl7802"]
    path = FreeRTOS-Plus/Source/FreeRTOS-Cellular-Modules/hl7802
    url = https://github.com/FreeRTOS/Lab-FreeRTOS-Cellular-Interface-Reference-Sierra-Wireless-HL7802.git
[submodule "FreeRTOS-Plus/Source/FreeRTOS-Cellular-Modules/sara-r4"]
    path = FreeRTOS-Plus/Source/FreeRTOS-Cellular-Modules/sara-r4
    url = https://github.com/FreeRTOS/Lab-FreeRTOS-Cellular-Interface-Reference-ublox-SARA-R4.git
 

情形二:已经克隆该仓库,但是没有克隆子模块

git submodule update --init --recursive

如果您已经克隆了没有子模块的存储库,则可以使用以下命令获取子模块。

特殊的,如果仅仅想克隆部分自己需要的子模块,可以在工程目录下的.gitmodules文件中指定。

另外,将HTTP地址换成SSH下载速度更快。

[submodule "FreeRTOS/Source"]
    path = FreeRTOS/Source
    url = git@github.com:TigerPiger/FreeRTOS-Kernel.git
[submodule "FreeRTOS/Test/CMock/CMock"]
    path = FreeRTOS/Test/CMock/CMock
    url = git@github.com:ThrowTheSwitch/CMock.git

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值