This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
library:git:generalcmd [2023/01/25 13:16] lhaosen [1.4 修改子模块] |
library:git:generalcmd [2023/02/16 17:13] (current) lhaosen [1.7 向下同步子模块仓库] |
||
---|---|---|---|
Line 280: | Line 280: | ||
指向主仓库记录子模块的路径 | 指向主仓库记录子模块的路径 | ||
gitdir: ../ | gitdir: ../ | ||
+ | |||
+ | |||
+ | ==== - 查看所有子模块 ==== | ||
+ | git submodule | ||
Line 306: | Line 310: | ||
- | ==== - 从已有的文件创建 git 子模块 ==== | + | ==== - 主仓库添加子模块(将已有的目录设为子模块)==== |
- | * 为sub-module创建一个单独的 git仓库 | + | * 为sub-module创建一个单独的git仓库 |
git checkout v2.0 | git checkout v2.0 | ||
Line 329: | Line 333: | ||
git submodule add https:// | git submodule add https:// | ||
git commit -m "add submodule version 1.0" | git commit -m "add submodule version 1.0" | ||
+ | |||
+ | ==== - 删除子模块 ==== | ||
+ | * 逆初始化模块,其中{MOD_NAME}为模块目录,执行后可发现模块目录被清空 | ||
+ | |||
+ | git submodule deinit < | ||
+ | |||
+ | * 删除.gitmodules中记录的模块信息(--cached选项清除.git/ | ||
+ | |||
+ | git rm --cached < | ||
+ | |||
+ | * 提交更改到代码库,可观察到' | ||
+ | |||
+ | git commit -am " | ||
==== - 向下同步子模块仓库 ==== | ==== - 向下同步子模块仓库 ==== | ||
+ | git submodule init | ||
git submodule update | git submodule update | ||
- | | + | |
+ | 或 | ||
git submodule update --init --recursive | git submodule update --init --recursive | ||
| | ||
| | ||
- | ==== 查看所有子模块 ==== | ||
- | git submodule | ||