【Git】(四)子模块

1、增加子模块

进入准备添加子模块所在的目录,例如library。

bash 复制代码
git submodule add -b 1.0.0.0 git@gitee.com:sunriver2000/SubModule.git

参数-b用于指定子模块分支。

2、更新子模块

cpp 复制代码
git submodule update --progress --init --recursive --force --remote -- "Library/SubModule"

3、gitmodules配置文件,更新子模块版本

bash 复制代码
git config -f .gitmodules submodule.Library/SubModule.branch 2.0.0.0
bash 复制代码
git submodule update --remote

然后提交到远程。

bash 复制代码
git commit -m "1、更新.modules文件。"
git push -u origin v1.0

4、删除子模块

1、删除子模块目录及源码

复制代码
rm -rf <子模块目录>

2、删除项目目录下.gitmodules文件中子模块相关条目

bash 复制代码
vi .gitmodules

3、删除配置项中子模块相关条目

bash 复制代码
vi .git/config

4、删除模块下的子模块目录

bash 复制代码
rm .git/module/<子模块目录>

5、清子模块缓存

bash 复制代码
git rm --cached 子模块名称
相关推荐
Doris_LMS1 天前
Git的强软硬回退(三)
运维·服务器·数据库·git·idea
瓜酷月..1 天前
GIT(了解)
git
misty youth1 天前
git命令常用指南
git·github
持续迷茫1 天前
lint-staged 中 --verbose 选项的深度解析
前端·git
lostElk1 天前
团队 Git 分管理全流程规范
git·github
亦是行人!1 天前
删除git中已经提交的target、logs、.idea文件
git
匆叔1 天前
Git下载全攻略
前端·git
奇树谦2 天前
Git配置:禁用全局HTTPS验证
git·网络协议·https
小安同学iter2 天前
在idea当中git的基础使用
git
初级代码游戏2 天前
Git或TortoiseGit的小BUG(可解决):空库报错Could not get hash of ““
git·bug