【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 子模块名称
相关推荐
一只楚楚猫4 小时前
一篇文章入门Git工具
git
Irissgwe5 小时前
第 6 篇:Git 分支进阶:分支策略、stash、bugfix 和 feature 开发
git
wok1575 小时前
Git Bash 执行中文命令报错 127:MSYS 参数编码 bug 排查与修复
git·bug·bash
霸道流氓气质20 小时前
CodeBuddy中使用 MCP 工具将 XMind 思维导图转换为 Markdown —— 实操流程汇总
git·myeclipse·xmind
OsDepK1 天前
mimo code安装教程
git·电脑·ai编程
NexTunnel1 天前
公司老项目还在 SVN,远程维护怎么做更稳?
git·svn·gitlab·远程工作·nextunnel
满天星83035772 天前
【Git】原理及使用(七) (多人协作 [下])
git
郡杰2 天前
Git基础与开发平台搭建
git·后端
钟智强2 天前
我警告了 329 天
git·php·wordpress·webshell
乐观的冷风2 天前
我们需要将文件添加到暂存区才能提交,而移除文件后是无法添加到暂存区的,那么怎么移除一个文件让GIT不再将其纳入版本控制呢?上图中GIT已经给出了说明:
git