Git工具-子模块

背景

在项目上工作时,如果需要在其中引用另外一个项目(第三方库或者其他),可以通过子模块来处理这个问题。

子模块允许将一个Git仓库作为另外一个Git仓库的子目录.

解决办法

拉取代码

git submodule add git_web_path filename

 会生成一个.gitmodules配置文件,这个文件记录了子项目的URL以及拉取到的本地子目录。

[submodule "restclient-cpp"]
    path = restclient-cpp
    url = https://github.com/mrtazz/restclient-cpp.git

 克隆一个带子模块的项目

git clone path

 然后会发现子项目的路径为空

git submodule init

git submodule update

扫描二维码关注公众号,回复: 5016709 查看本文章

猜你喜欢

转载自blog.csdn.net/weixin_42670653/article/details/83828168