【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 子模块名称
相关推荐
Zucker n28 分钟前
配置 GitHub SSH 密钥认证(自用笔记)
git
GoodStudyAndDayDayUp7 小时前
GXW-Git规范
git
weixin_307779131 天前
Git中获取一个目录下所有文件的最后修改人的邮箱
开发语言·git·算法
ynchyong1 天前
Git 急救指南:手滑 add / commit 错了,怎么优雅地撤回
git·手滑
Zucker n2 天前
Git 常用命令速查(自用笔记)
git
雪碧聊技术2 天前
Git实战:在Idea中,如何只将分支 A 某次 Commit记录的单个文件同步到分支 B?一文详解|保姆教程
git·文件对比,一键应用
Mortalbreeze2 天前
Git 基础篇(三):分支管理
git
Zucker n2 天前
安装 Git for Windows(自用笔记)
笔记·git
棒子胡豆3 天前
Git总结
git
`流年づ5 天前
联邦学习-安全聚合
git·安全·github