【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 子模块名称
相关推荐
小前端学徒1 小时前
重新修改未提交到远程分支不是最后一次commit的内容
git
执键行天涯1 小时前
idea中已经被git缓存追踪的文件,如何让git重新忽略
git·缓存·intellij-idea
hkhkhkhkh1232 小时前
Git push 失败(remote unpack failed: Missing tree)解决方案
linux·git
拾贰_C3 小时前
【anaconda】anaconda安装配置,git安装配置以及pytorch安装
人工智能·pytorch·git
Just_Paranoid5 小时前
【Gerrit Patch】批量下载 Gerrit 提交的 Patch
git·gerrit·shell·patch
T - mars18 小时前
Pycharm中使用git
ide·git·pycharm
jason_yang20 小时前
Workspace搭建Vue3+组件分离的Monorepo项目
git·npm·前端工程化
鸽鸽程序猿1 天前
【Git】Git 简介及基本操作
git
ziyue75751 天前
idea终端添加git-bash,支持linux的shell语法
linux·git·bash·idea·软件
风也温柔☆2 天前
idea 拉取分支git pull报错 The branch to pull from should be selected
git·intellij-idea·debug·git pull