背景
在项目上工作时,如果需要在其中引用另外一个项目(第三方库或者其他),可以通过子模块来处理这个问题。
子模块允许将一个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