在父倉庫中添加子倉庫
-
創建父倉庫(parent)
clone地址:: https://gitee.com/xxx/parent.git -
創建子倉庫(child1)
clone地址:: https://gitee.com/xxx/child1.git -
創建子倉庫(child2)
clone地址:: https://gitee.com/xxx/child2.git注: 創建倉庫的時候勾選README.md,保證不是空倉庫
-
父倉庫添加子倉庫依賴
第一步: 克隆父倉庫
$ git clone https://gitee.com/xxx/parent.git
第二步: 添加子倉庫
$ git submodule add https://gitee.com/xxx/child1.git
$ git submodule add https://gitee.com/xxx/child2.git
第三步: push到父倉庫
$ git add .
$ git commit -m ‘add submodule’
$ git push注: 當第二步(添加子倉庫)操作完成之後,項目中將生成…gitmodules文件
文件內容如下:
[submodule “child1”]
path = child1
url = https://gitee.com/xxx/child1.git
[submodule “child2”]
path = child2
url = https://gitee.com/xxx/child2.git -
遞歸克隆父倉庫
$ git clone --recursive https://gitee.com/xxx/parent.git -
更新子倉庫
6.1 更新已存在的倉庫代碼
git submodule foreach git pull origin master
6.2 更新新增的子倉庫代碼
git submodule update