关于git:git-submodule-子仓库使用

9次阅读

共计 915 个字符,预计需要花费 3 分钟才能阅读完成。

git 仓库嵌套子仓库应用计划

  • 话不多说,间接贴代码
git clone https://father.git
cd father
# 子仓库 1
git submodule add http://child1.git
git status
git commit -am "add child1"
git pull origin branch
git push origin branch
# 子仓库 2
git submodule add http://child2.git
git commit -am "add child2"
git pull origin branch
git push origin branch
  • 如果 git submodule 过程中遇到问题如
warning: adding embedded git repository: 子仓库 name
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: 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> 子仓库 name
hint: 
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint: 
hint:     git rm --cached 子仓库 name
  • 这个时候就证实你没有 submodule add 胜利,须要将缓存中的革除。
git rm --cached 子仓库 name, 此时如果报错如下:# error
fatal: not removing 'module-name' recursively without -r
# 将命令批改成
git rm -r --cached module-name
  • submodule add 胜利之后 git status 查看可看到 new file .gitmodules
  • 这个时候证实胜利了。

对于子仓库的应用心愿能帮到你,有问题能够留言。

正文完
 0