当前位置:   article > 正文

Git仓库子模块管理_git 子模块管理

git 子模块管理

子模块允许你将一个 Git 仓库当作另外一个Git仓库的子目录。这允许你克隆另外一个仓库到你的项目中并且保持你的提交相对独立。配置文件在.gitmodules

1)命令速查

git submodule --help # 查看说明

## 克隆代码时带上子模块
git clone --recurse-submodules <repository>

## 初始化本地.gitmodules文件
git submodule init

## 添加子模块
git submodule add <repository> [<path>]

## 拉取所有子模块
git submodule foreach git pull

## 更新子模块
git submodule update --init --recursive --remote [<path>]
git submodule foreach git submodule update

## 将子模块切到指定分支
git submodule set-branch -b master [<path>]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号