File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -106,19 +106,30 @@ spark git update -p ~/workspace -p ~/projects
106106详细文档: [ docs/usage/update.md] ( docs/usage/update.md )
107107
108108#### ` spark git submodule `
109- 将当前目录下的 Git 仓库添加为子模块,无需重新克隆 。
109+ 将本地 Git 仓库添加为子模块,或将远程仓库克隆为子模块 。
110110
111+ ** 本地模式** :
111112``` bash
112113spark git submodule add # 添加当前目录下的仓库
113114spark git submodule add -p /path/to/repos # 添加指定目录下的仓库
115+ spark git submodule add ./spark-cli # 将指定目录作为子模块添加
114116```
115117
116118| 选项 | 说明 |
117119| ------| ------|
118120| ` -n, --name ` | 子模块路径名称 (默认: 仓库名) |
119121
122+ ** 智能检测行为** :
123+
124+ | 场景 | 输出 |
125+ | ------| ------|
126+ | 目标已是 submodule(160000) | ` Skipping <name>: already as submodule ` |
127+ | 目标与父仓库 URL 相同(worktree) | ` Skipping <name>: already as submodule ` |
128+ | 目录存在但不是 submodule | ` Skipping <name>: directory already exists (use 'git submodule add' manually) ` |
129+ | 正常添加 | ` Adding submodule: <name> (<url>) ` |
130+
120131#### ` spark git sync `
121- 同步当前仓库中所有子模块到最新版本。
132+ 同步当前仓库中所有子模块到最新版本。包含 ` git submodule update --init ` ,确保缺失的子模块也会被 clone。
122133
123134``` bash
124135spark git sync ./my-repo
Original file line number Diff line number Diff line change @@ -68,6 +68,15 @@ spark git submodule add [-p <path>]
6868
6969无参数。
7070
71+ ** 智能检测行为** :
72+
73+ | 场景 | 输出 |
74+ | ------| ------|
75+ | 目标已是 submodule(160000) | ` Skipping <name>: already as submodule ` |
76+ | 目标与父仓库 URL 相同(worktree) | ` Skipping <name>: already as submodule ` |
77+ | 目录存在但不是 submodule | ` Skipping <name>: directory already exists (use 'git submodule add' manually) ` |
78+ | 正常添加 | ` Adding submodule: <name> (<url>) ` |
79+
7180### 远程模式
7281
7382```
@@ -95,6 +104,11 @@ spark git sync [repo-path]
95104| ------| ------| --------| ------| ------|
96105| ` repo-path ` | string | ` . ` | 否 | 仓库路径 |
97106
107+ ** 流程** :
108+ 1 . ` git fetch --all ` — 获取所有远程最新代码
109+ 2 . ` git submodule update --init ` — 初始化缺失的子模块(从 ` .gitmodules ` 中读取)
110+ 3 . ` git submodule update --remote --merge ` — 更新所有子模块到最新版本并合并
111+
98112---
99113
100114## spark git gitcode
Original file line number Diff line number Diff line change @@ -44,13 +44,22 @@ spark git update -p ~/ws -p ~/projects # 多个目录
4444
4545| 标志 | 简写 | 默认值 | 说明 |
4646| ------| ------| --------| ------|
47-
47+ | ` -p, --path ` | | ` . ` | 包含 Git 仓库的目录路径 |
4848
4949``` bash
5050spark git submodule add ./repos # 将本地文件夹中所有 GitHub 仓库添加为 submodule
51- spark git submodule add https://github.com/user/repo # 添加远程仓库
51+ spark git submodule add ./spark-cli # 将指定目录作为子模块添加
5252```
5353
54+ ** 智能检测行为** :
55+
56+ | 场景 | 输出 |
57+ | ------| ------|
58+ | 目标已是 submodule(160000) | ` Skipping <name>: already as submodule ` |
59+ | 目标与父仓库 URL 相同(worktree) | ` Skipping <name>: already as submodule ` |
60+ | 目录存在但不是 submodule | ` Skipping <name>: directory already exists (use 'git submodule add' manually) ` |
61+ | 正常添加 | ` Adding submodule: <name> (<url>) ` |
62+
5463### 模式 2:添加远程仓库为子模块
5564
5665克隆远程 Git 仓库并将其添加为子模块。
@@ -83,6 +92,13 @@ spark git submodule add user/repo
8392spark git sync ./my-repo # 同步指定仓库
8493```
8594
95+ ** 流程** :
96+ 1 . ` git fetch --all ` — 获取所有远程最新代码
97+ 2 . ` git submodule update --init ` — 初始化缺失的子模块(从 ` .gitmodules ` 中读取)
98+ 3 . ` git submodule update --remote --merge ` — 更新所有子模块到最新版本并合并
99+
100+ ** 注意** :` --init ` 确保即使子模块目录在本地缺失,也会从远程 clone 下来。
101+
86102---
87103
88104## spark git gitcode
You can’t perform that action at this time.
0 commit comments