git仓库嵌套子仓库应用计划
- 话不多说,间接贴代码
git clone https://father.gitcd father# 子仓库1git submodule add http://child1.gitgit statusgit commit -am "add child1"git pull origin branchgit push origin branch# 子仓库2git submodule add http://child2.gitgit commit -am "add child2"git pull origin branchgit push origin branch
- 如果git submodule 过程中遇到问题如
warning: adding embedded git repository: 子仓库namehint: You've added another git repository inside your current repository.hint: Clones of the outer repository will not contain the contents ofhint: the embedded repository and will not know how to obtain it.hint: If you meant to add a submodule, use:hint: hint: git submodule add <url> 子仓库namehint: hint: If you added this path by mistake, you can remove it from thehint: index with:hint: hint: git rm --cached 子仓库name
- 这个时候就证实你没有submodule add 胜利,须要将缓存中的革除。
git rm --cached 子仓库name,此时如果报错如下:# errorfatal: not removing 'module-name' recursively without -r# 将命令批改成git rm -r --cached module-name
- submodule add 胜利之后 git status 查看可看到 new file .gitmodules
- 这个时候证实胜利了。
对于子仓库的应用心愿能帮到你,有问题能够留言。