惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
N
Netflix TechBlog - Medium
P
Proofpoint News Feed
D
Docker
J
Java Code Geeks
L
LangChain Blog
Microsoft Security Blog
Microsoft Security Blog
The GitHub Blog
The GitHub Blog
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
月光博客
月光博客
T
Tailwind CSS Blog
M
MIT News - Artificial intelligence
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
腾讯CDC
罗磊的独立博客
U
Unit 42
爱范儿
爱范儿
Vercel News
Vercel News
MyScale Blog
MyScale Blog

时间的朋友

Windows 命令行密码重置 Anaconda安装 typescript 注解解读1 Konvajs Shape加载自定义图片 sshpass 使用 why-is-node-running webgl笔记 SharedArrayBuffer is not defined blender 常用快捷键 | 时间的朋友 vue -- v3.4commit提交记录2 vue2 升级vue3报错问题整理 着色器 expressjs 源码 hyper-V arch linux 网络配置 element input数字格式化 three 拼接货架 WebAudio笔记 Windows nginx重启bat脚本 vue -- v3.4commit提交记录 URI malformed vue3 -- Class 对象在组件中使用范例 | 时间的朋友 ruby 安装和升级 element-plus 老版本cascader使用卡死问题 vue3 内置Transition组件 | 时间的朋友 前端memo的实现 | 时间的朋友 Vue -- vue-class-component源码 | 时间的朋友 linux 优化脚本 typescript 装饰器 | 时间的朋友 microbundle 源码 | 时间的朋友 WSL2问题解决WslRegisterDistribution failed with error: 0x800701bc
git submodule 使用方法 | 时间的朋友
2021-09-18 · via 时间的朋友

Published: · LastMod: November 27, 2023 · 449 words

submodule 🔗

平时我们在管理项目的时候都是用git来进行管理,git管理很方便,但是一旦项目越来越大,单个git仓库管理起来就没有那么方便了 这个时候我们就可以使用git的另一个工具submodule来管理我们的项目

submodule 是用来管理主项目和子项目之间的关系。

使用 🔗

1
git submodule add <submodule_url>

此时主项目中会多出一个文件.gitmodules,此文件是用来管理子模块的

以此博客为例

1
2
3
[submodule "themes/LoveIt"]
	path = themes/LoveIt
	url = https://github.com/dillonzq/LoveIt.git

安装 🔗

平时我们clone项目都是使用git clone xxx下载项目,如果项目中有子模块,这种方式就不能下载下来了

如果希望子模块代码也获取到,一种方式是在克隆主项目的时候带上参数 --recurse-submodules,这样会递归地将项目中所有子模块的代码拉取。

另一种方式

git submodule init && git submodule update

更新所有模块 🔗

1
git submodule foreach 'git pull origin master'
1
git submodule update --init --recursive --remote

单独更新一个子模块 🔗

1
git submodule update --init --remote a/submodule/path

删除某个子模块 🔗

git submodule deinit project-sub-1

git rm project-sub-1

issues 🔗

1.版本跟踪里出现git submodule commit xxxxx错误 🔗

解决方法

git submodule update

2. git 子模块submodule dirty 🔗

1
git config --global diff.ignoreSubmodules dirty

修改.git/config

1
2
[diff]
ignoreSubmodules = dirty