ccjk 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.ja.md +455 -0
- package/README.ko.md +455 -0
- package/README.md +550 -0
- package/README.zh-CN.md +488 -0
- package/bin/ccjk.mjs +2 -0
- package/dist/chunks/api-providers.mjs +89 -0
- package/dist/chunks/claude-code-config-manager.mjs +733 -0
- package/dist/chunks/claude-code-incremental-manager.mjs +603 -0
- package/dist/chunks/codex-config-switch.mjs +427 -0
- package/dist/chunks/codex-provider-manager.mjs +232 -0
- package/dist/chunks/codex-uninstaller.mjs +404 -0
- package/dist/chunks/commands.mjs +120 -0
- package/dist/chunks/features.mjs +642 -0
- package/dist/chunks/simple-config.mjs +10445 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +5972 -0
- package/dist/i18n/locales/en/api.json +63 -0
- package/dist/i18n/locales/en/ccjk.json +276 -0
- package/dist/i18n/locales/en/ccr.json +65 -0
- package/dist/i18n/locales/en/cli.json +57 -0
- package/dist/i18n/locales/en/codex.json +124 -0
- package/dist/i18n/locales/en/cometix.json +29 -0
- package/dist/i18n/locales/en/common.json +20 -0
- package/dist/i18n/locales/en/configuration.json +77 -0
- package/dist/i18n/locales/en/errors.json +26 -0
- package/dist/i18n/locales/en/installation.json +80 -0
- package/dist/i18n/locales/en/interview.json +104 -0
- package/dist/i18n/locales/en/language.json +19 -0
- package/dist/i18n/locales/en/mcp.json +38 -0
- package/dist/i18n/locales/en/menu.json +51 -0
- package/dist/i18n/locales/en/multi-config.json +79 -0
- package/dist/i18n/locales/en/shencha.json +14 -0
- package/dist/i18n/locales/en/team.json +7 -0
- package/dist/i18n/locales/en/tools.json +42 -0
- package/dist/i18n/locales/en/uninstall.json +56 -0
- package/dist/i18n/locales/en/updater.json +25 -0
- package/dist/i18n/locales/en/workflow.json +25 -0
- package/dist/i18n/locales/zh-CN/api.json +63 -0
- package/dist/i18n/locales/zh-CN/ccjk.json +276 -0
- package/dist/i18n/locales/zh-CN/ccr.json +65 -0
- package/dist/i18n/locales/zh-CN/cli.json +57 -0
- package/dist/i18n/locales/zh-CN/codex.json +124 -0
- package/dist/i18n/locales/zh-CN/cometix.json +29 -0
- package/dist/i18n/locales/zh-CN/common.json +20 -0
- package/dist/i18n/locales/zh-CN/configuration.json +77 -0
- package/dist/i18n/locales/zh-CN/errors.json +26 -0
- package/dist/i18n/locales/zh-CN/installation.json +80 -0
- package/dist/i18n/locales/zh-CN/interview.json +104 -0
- package/dist/i18n/locales/zh-CN/language.json +19 -0
- package/dist/i18n/locales/zh-CN/mcp.json +38 -0
- package/dist/i18n/locales/zh-CN/menu.json +51 -0
- package/dist/i18n/locales/zh-CN/multi-config.json +79 -0
- package/dist/i18n/locales/zh-CN/shencha.json +14 -0
- package/dist/i18n/locales/zh-CN/team.json +7 -0
- package/dist/i18n/locales/zh-CN/tools.json +42 -0
- package/dist/i18n/locales/zh-CN/uninstall.json +56 -0
- package/dist/i18n/locales/zh-CN/updater.json +25 -0
- package/dist/i18n/locales/zh-CN/workflow.json +25 -0
- package/dist/index.d.mts +2644 -0
- package/dist/index.d.ts +2644 -0
- package/dist/index.mjs +1706 -0
- package/package.json +157 -0
- package/templates/CLAUDE.md +219 -0
- package/templates/claude-code/CLAUDE.md +250 -0
- package/templates/claude-code/common/settings.json +38 -0
- package/templates/claude-code/en/workflow/bmad/commands/bmad-init.md +165 -0
- package/templates/claude-code/en/workflow/common/agents/get-current-datetime.md +29 -0
- package/templates/claude-code/en/workflow/common/agents/init-architect.md +114 -0
- package/templates/claude-code/en/workflow/common/commands/init-project.md +53 -0
- package/templates/claude-code/en/workflow/plan/agents/planner.md +116 -0
- package/templates/claude-code/en/workflow/plan/agents/ui-ux-designer.md +91 -0
- package/templates/claude-code/en/workflow/plan/commands/feat.md +105 -0
- package/templates/claude-code/zh-CN/workflow/bmad/commands/bmad-init.md +172 -0
- package/templates/claude-code/zh-CN/workflow/common/agents/get-current-datetime.md +29 -0
- package/templates/claude-code/zh-CN/workflow/common/agents/init-architect.md +114 -0
- package/templates/claude-code/zh-CN/workflow/common/commands/init-project.md +53 -0
- package/templates/claude-code/zh-CN/workflow/plan/agents/planner.md +116 -0
- package/templates/claude-code/zh-CN/workflow/plan/agents/ui-ux-designer.md +91 -0
- package/templates/claude-code/zh-CN/workflow/plan/commands/feat.md +105 -0
- package/templates/codex/common/config.toml +0 -0
- package/templates/common/output-styles/en/casual-friendly.md +97 -0
- package/templates/common/output-styles/en/engineer-professional.md +88 -0
- package/templates/common/output-styles/en/expert-concise.md +93 -0
- package/templates/common/output-styles/en/laowang-engineer.md +127 -0
- package/templates/common/output-styles/en/nekomata-engineer.md +120 -0
- package/templates/common/output-styles/en/ojousama-engineer.md +121 -0
- package/templates/common/output-styles/en/teaching-mode.md +102 -0
- package/templates/common/output-styles/en/technical-precise.md +101 -0
- package/templates/common/output-styles/zh-CN/engineer-professional.md +89 -0
- package/templates/common/output-styles/zh-CN/laowang-engineer.md +127 -0
- package/templates/common/output-styles/zh-CN/nekomata-engineer.md +120 -0
- package/templates/common/output-styles/zh-CN/ojousama-engineer.md +121 -0
- package/templates/common/workflow/git/en/git-cleanBranches.md +102 -0
- package/templates/common/workflow/git/en/git-commit.md +205 -0
- package/templates/common/workflow/git/en/git-rollback.md +90 -0
- package/templates/common/workflow/git/en/git-worktree.md +276 -0
- package/templates/common/workflow/git/zh-CN/git-cleanBranches.md +102 -0
- package/templates/common/workflow/git/zh-CN/git-commit.md +205 -0
- package/templates/common/workflow/git/zh-CN/git-rollback.md +90 -0
- package/templates/common/workflow/git/zh-CN/git-worktree.md +276 -0
- package/templates/common/workflow/interview/en/interview.md +212 -0
- package/templates/common/workflow/interview/zh-CN/interview.md +212 -0
- package/templates/common/workflow/sixStep/en/workflow.md +251 -0
- package/templates/common/workflow/sixStep/zh-CN/workflow.md +215 -0
- package/templates/industry/devops/en/ci-cd-pipeline.md +410 -0
- package/templates/industry/web-dev/en/api-design.md +299 -0
- package/templates/industry/web-dev/en/react-nextjs-setup.md +236 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 安全查找并清理已合并或过期的 Git 分支,支持 dry-run 模式与自定义基准/保护分支
|
|
3
|
+
allowed-tools: Read(**), Exec(git fetch, git config, git branch, git remote, git push, git for-each-ref, git log), Write()
|
|
4
|
+
argument-hint: [--base <branch>] [--stale <days>] [--remote] [--force] [--dry-run] [--yes]
|
|
5
|
+
# examples:
|
|
6
|
+
# - /git-cleanBranches --dry-run
|
|
7
|
+
# - /git-cleanBranches --base release/v2.1 --stale 90
|
|
8
|
+
# - /git-cleanBranches --remote --yes
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Claude Command: Clean Branches
|
|
12
|
+
|
|
13
|
+
该命令**安全地**识别并清理**已合并**或**长期未更新 (stale)** 的 Git 分支。
|
|
14
|
+
默认以**只读预览 (`--dry-run`)** 模式运行,需明确指令才会执行删除操作。
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# [最安全] 预览将要清理的分支,不执行任何删除
|
|
22
|
+
/git-cleanBranches --dry-run
|
|
23
|
+
|
|
24
|
+
# 清理已合并到 main 且超过 90 天未动的本地分支 (需逐一确认)
|
|
25
|
+
/git-cleanBranches --stale 90
|
|
26
|
+
|
|
27
|
+
# 清理已合并到 release/v2.1 的本地与远程分支 (自动确认)
|
|
28
|
+
/git-cleanBranches --base release/v2.1 --remote --yes
|
|
29
|
+
|
|
30
|
+
# [危险] 强制删除一个未合并的本地分支
|
|
31
|
+
/git-cleanBranches --force outdated-feature
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Options
|
|
35
|
+
|
|
36
|
+
- `--base <branch>`:指定清理的基准分支(默认为仓库的 `main`/`master`)。
|
|
37
|
+
- `--stale <days>`:清理超过指定天数未提交的分支(默认不启用)。
|
|
38
|
+
- `--remote`:同时清理远程已合并/过期的分支。
|
|
39
|
+
- `--dry-run`:**默认行为**。仅列出将要删除的分支,不执行任何操作。
|
|
40
|
+
- `--yes`:跳过逐一确认的步骤,直接删除所有已识别的分支(适合 CI/CD)。
|
|
41
|
+
- `--force`:使用 `-D` 强制删除本地分支(即使未合并)。
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## What This Command Does
|
|
46
|
+
|
|
47
|
+
1. **配置与安全预检**
|
|
48
|
+
- **更新信息**:自动执行 `git fetch --all --prune`,确保分支状态最新。
|
|
49
|
+
- **读取保护分支**:从 Git 配置读取不应被清理的分支列表(见下文“Configuration”)。
|
|
50
|
+
- **确定基准**:使用 `--base` 参数或自动识别的 `main`/`master` 作为比较基准。
|
|
51
|
+
|
|
52
|
+
2. **分析识别(Find)**
|
|
53
|
+
- **已合并分支**:找出已完全合并到 `--base` 的本地(及远程,如加 `--remote`)分支。
|
|
54
|
+
- **过期分支**:如指定 `--stale <days>`,找出最后一次提交在 N 天前的分支。
|
|
55
|
+
- **排除保护分支**:从待清理列表中移除所有已配置的保护分支。
|
|
56
|
+
|
|
57
|
+
3. **报告预览(Report)**
|
|
58
|
+
- 清晰列出“将要删除的已合并分支”与“将要删除的过期分支”。
|
|
59
|
+
- 若无 `--yes` 参数,**命令到此结束**,等待用户确认后再次执行(不带 `--dry-run`)。
|
|
60
|
+
|
|
61
|
+
4. **执行清理(Execute)**
|
|
62
|
+
- **仅在不带 `--dry-run` 且用户确认后**(或带 `--yes`)执行。
|
|
63
|
+
- 逐一删除已识别的分支,除非用户在交互式确认中选择跳过。
|
|
64
|
+
- 本地用 `git branch -d <branch>`;远程用 `git push origin --delete <branch>`。
|
|
65
|
+
- 若指定 `--force`,本地删除会改用 `git branch -D <branch>`。
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Configuration (一次配置,永久生效)
|
|
70
|
+
|
|
71
|
+
为防止误删重要分支(如 `develop`, `release/*`),请在仓库的 Git 配置中添加保护规则。命令会自动读取。
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# 保护 develop 分支
|
|
75
|
+
git config --add branch.cleanup.protected develop
|
|
76
|
+
|
|
77
|
+
# 保护所有 release/ 开头的分支 (通配符)
|
|
78
|
+
git config --add branch.cleanup.protected 'release/*'
|
|
79
|
+
|
|
80
|
+
# 查看所有已配置的保护分支
|
|
81
|
+
git config --get-all branch.cleanup.protected
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Best Practices for Embedded Devs
|
|
87
|
+
|
|
88
|
+
- **优先 `--dry-run`**:养成先预览再执行的习惯。
|
|
89
|
+
- **活用 `--base`**:维护长期 `release` 分支时,用它来清理已合并到该 release 的 `feature` 或 `hotfix` 分支。
|
|
90
|
+
- **谨慎 `--force`**:除非你百分百确定某个未合并分支是无用功,否则不要强制删除。
|
|
91
|
+
- **团队协作**:在清理共享的远程分支前,先在团队频道通知一声。
|
|
92
|
+
- **定期运行**:每月或每季度运行一次,保持仓库清爽。
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Why This Version Is Better
|
|
97
|
+
|
|
98
|
+
- ✅ **更安全**:默认只读预览,且有可配置的保护分支列表。
|
|
99
|
+
- ✅ **更灵活**:支持自定义基准分支,完美适配 `release` / `develop` 工作流。
|
|
100
|
+
- ✅ **更兼容**:避免了在不同系统上行为不一的 `date -d` 等命令。
|
|
101
|
+
- ✅ **更直观**:将复杂的 16 步清单,浓缩成一个带安全选项的、可直接执行的命令。
|
|
102
|
+
- ✅ **风格一致**:与 `/commit` 命令共享相似的参数设计与文档结构。
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 仅用 Git 分析改动并自动生成 conventional commit 信息(可选 emoji);必要时建议拆分提交,默认运行本地 Git 钩子(可 --no-verify 跳过)
|
|
3
|
+
allowed-tools: Read(**), Exec(git status, git diff, git add, git restore --staged, git commit, git rev-parse, git config), Write(.git/COMMIT_EDITMSG)
|
|
4
|
+
argument-hint: [--no-verify] [--all] [--amend] [--signoff] [--emoji] [--scope <scope>] [--type <type>]
|
|
5
|
+
# examples:
|
|
6
|
+
# - /git-commit # 分析当前改动,生成提交信息
|
|
7
|
+
# - /git-commit --all # 暂存所有改动并提交
|
|
8
|
+
# - /git-commit --no-verify # 跳过 Git 钩子检查
|
|
9
|
+
# - /git-commit --emoji # 在提交信息中包含 emoji
|
|
10
|
+
# - /git-commit --scope ui --type feat # 指定作用域和类型
|
|
11
|
+
# - /git-commit --amend --signoff # 修补上次提交并签名
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Claude Command: Commit (Git-only)
|
|
15
|
+
|
|
16
|
+
该命令在**不依赖任何包管理器/构建工具**的前提下,仅通过 **Git**:
|
|
17
|
+
|
|
18
|
+
- 读取改动(staged/unstaged)
|
|
19
|
+
- 判断是否需要**拆分为多次提交**
|
|
20
|
+
- 为每个提交生成 **Conventional Commits** 风格的信息(可选 emoji)
|
|
21
|
+
- 按需执行 `git add` 与 `git commit`(默认运行本地 Git 钩子;可 `--no-verify` 跳过)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
/git-commit
|
|
29
|
+
/git-commit --no-verify
|
|
30
|
+
/git-commit --emoji
|
|
31
|
+
/git-commit --all --signoff
|
|
32
|
+
/git-commit --amend
|
|
33
|
+
/git-commit --scope ui --type feat --emoji
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Options
|
|
37
|
+
|
|
38
|
+
- `--no-verify`:跳过本地 Git 钩子(`pre-commit`/`commit-msg` 等)。
|
|
39
|
+
- `--all`:当暂存区为空时,自动 `git add -A` 将所有改动纳入本次提交。
|
|
40
|
+
- `--amend`:在不创建新提交的情况下**修补**上一次提交(保持提交作者与时间,除非本地 Git 配置另有指定)。
|
|
41
|
+
- `--signoff`:附加 `Signed-off-by` 行(遵循 DCO 流程时使用)。
|
|
42
|
+
- `--emoji`:在提交信息中包含 emoji 前缀(省略则使用纯文本)。
|
|
43
|
+
- `--scope <scope>`:指定提交作用域(如 `ui`、`docs`、`api`),写入消息头部。
|
|
44
|
+
- `--type <type>`:强制提交类型(如 `feat`、`fix`、`docs` 等),覆盖自动判断。
|
|
45
|
+
|
|
46
|
+
> 注:如框架不支持交互式确认,可在 front-matter 中开启 `confirm: true` 以避免误操作。
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## What This Command Does
|
|
51
|
+
|
|
52
|
+
1. **仓库/分支校验**
|
|
53
|
+
- 通过 `git rev-parse --is-inside-work-tree` 判断是否位于 Git 仓库。
|
|
54
|
+
- 读取当前分支/HEAD 状态;如处于 rebase/merge 冲突状态,先提示处理冲突后再继续。
|
|
55
|
+
|
|
56
|
+
2. **改动检测**
|
|
57
|
+
- 用 `git status --porcelain` 与 `git diff` 获取已暂存与未暂存的改动。
|
|
58
|
+
- 若已暂存文件为 0:
|
|
59
|
+
- 若传入 `--all` → 执行 `git add -A`。
|
|
60
|
+
- 否则提示你选择:继续仅分析未暂存改动并给出**建议**,或取消命令后手动分组暂存。
|
|
61
|
+
|
|
62
|
+
3. **拆分建议(Split Heuristics)**
|
|
63
|
+
- 按**关注点**、**文件模式**、**改动类型**聚类(示例:源代码 vs 文档、测试;不同目录/包;新增 vs 删除)。
|
|
64
|
+
- 若检测到**多组独立变更**或 diff 规模过大(如 > 300 行 / 跨多个顶级目录),建议拆分提交,并给出每一组的 pathspec(便于后续执行 `git add <paths>`)。
|
|
65
|
+
|
|
66
|
+
4. **提交信息生成(Conventional 规范,可选 Emoji)**
|
|
67
|
+
- 自动推断 `type`(`feat`/`fix`/`docs`/`refactor`/`test`/`chore`/`perf`/`style`/`ci`/`revert` …)与可选 `scope`。
|
|
68
|
+
- 生成消息头:`[<emoji>] <type>(<scope>)?: <subject>`(首行 ≤ 72 字符,祈使语气,仅在使用 `--emoji` 时包含 emoji)。
|
|
69
|
+
- 生成消息体:
|
|
70
|
+
- 必须在 subject 之后空一行。
|
|
71
|
+
- 使用列表格式,每项以 `-` 开头。
|
|
72
|
+
- 每项**必须使用动词开头的祈使句**(如 "add…"、"fix…"、"update…")。
|
|
73
|
+
- **禁止使用冒号分隔的格式**(如 ~~"Feature: description"~~、~~"Impl: content"~~)。
|
|
74
|
+
- 说明变更的动机、实现要点或影响范围(3 项以内为宜)。
|
|
75
|
+
- 生成消息脚注(如有):
|
|
76
|
+
- 必须在 Body 之后空一行。
|
|
77
|
+
- **BREAKING CHANGE**:若存在破坏性变更,必须包含 `BREAKING CHANGE: <description>`,或在类型后添加感叹号(如 `feat!:`)。
|
|
78
|
+
- 其它脚注采用 git trailer 格式(如 `Closes #123`、`Refs: #456`、`Reviewed-by: Name`)。
|
|
79
|
+
- 根据 Git 历史提交的主要语言选择提交信息语言。优先检查最近提交主题(例如 `git log -n 50 --pretty=%s`)判断中文/英文;若无法判断,则回退到仓库主要语言或英文。
|
|
80
|
+
- 将草稿写入 `.git/COMMIT_EDITMSG`,并用于 `git commit`。
|
|
81
|
+
|
|
82
|
+
5. **执行提交**
|
|
83
|
+
- 单提交场景:`git commit [-S] [--no-verify] [-s] -F .git/COMMIT_EDITMSG`
|
|
84
|
+
- 多提交场景(如接受拆分建议):按分组给出 `git add <paths> && git commit ...` 的明确指令;若允许执行则逐一完成。
|
|
85
|
+
|
|
86
|
+
6. **安全回滚**
|
|
87
|
+
- 如误暂存,可用 `git restore --staged <paths>` 撤回暂存(命令会给出指令,不修改文件内容)。
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Best Practices for Commits
|
|
92
|
+
|
|
93
|
+
- **Atomic commits**:一次提交只做一件事,便于回溯与审阅。
|
|
94
|
+
- **先分组再提交**:按目录/模块/功能点拆分。
|
|
95
|
+
- **清晰主题**:首行 ≤ 72 字符,祈使语气。
|
|
96
|
+
- **正文含上下文**:说明动机、方案、影响范围(禁止冒号分隔格式)。
|
|
97
|
+
- **遵循 Conventional Commits**:`<type>(<scope>): <subject>`。
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Type 与 Emoji 映射(使用 --emoji 时)
|
|
102
|
+
|
|
103
|
+
- ✨ `feat`:新增功能
|
|
104
|
+
- 🐛 `fix`:缺陷修复(含 🔥 删除代码/文件、🚑️ 紧急修复、👽️ 适配外部 API 变更、🔒️ 安全修复、🚨 解决告警、💚 修复 CI)
|
|
105
|
+
- 📝 `docs`:文档与注释
|
|
106
|
+
- 🎨 `style`:风格/格式(不改语义)
|
|
107
|
+
- ♻️ `refactor`:重构(不新增功能、不修缺陷)
|
|
108
|
+
- ⚡️ `perf`:性能优化
|
|
109
|
+
- ✅ `test`:新增/修复测试、快照
|
|
110
|
+
- 🔧 `chore`:构建/工具/杂务(合并分支、更新配置、发布标记、依赖 pin、.gitignore 等)
|
|
111
|
+
- 👷 `ci`:CI/CD 配置与脚本
|
|
112
|
+
- ⏪️ `revert`:回滚提交
|
|
113
|
+
- 💥 `feat`:破坏性变更(`BREAKING CHANGE:` 段落中说明)
|
|
114
|
+
|
|
115
|
+
> 若传入 `--type`/`--scope`,将**覆盖**自动推断。
|
|
116
|
+
> 仅在指定 `--emoji` 标志时才会包含 emoji。
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Guidelines for Splitting Commits
|
|
121
|
+
|
|
122
|
+
1. **不同关注点**:互不相关的功能/模块改动应拆分。
|
|
123
|
+
2. **不同类型**:不要将 `feat`、`fix`、`refactor` 混在同一提交。
|
|
124
|
+
3. **文件模式**:源代码 vs 文档/测试/配置分组提交。
|
|
125
|
+
4. **规模阈值**:超大 diff(示例:>300 行或跨多个顶级目录)建议拆分。
|
|
126
|
+
5. **可回滚性**:确保每个提交可独立回退。
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Examples
|
|
131
|
+
|
|
132
|
+
**Good (使用 --emoji)**
|
|
133
|
+
|
|
134
|
+
```text
|
|
135
|
+
- ✨ feat(ui): add user authentication flow
|
|
136
|
+
- 🐛 fix(api): handle token refresh race condition
|
|
137
|
+
- 📝 docs: update API usage examples
|
|
138
|
+
- ♻️ refactor(core): extract retry logic into helper
|
|
139
|
+
- ✅ test: add unit tests for rate limiter
|
|
140
|
+
- 🔧 chore: update git hooks and repository settings
|
|
141
|
+
- ⏪️ revert: revert "feat(core): introduce streaming API"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Good (不使用 --emoji)**
|
|
145
|
+
|
|
146
|
+
```text
|
|
147
|
+
- feat(ui): add user authentication flow
|
|
148
|
+
- fix(api): handle token refresh race condition
|
|
149
|
+
- docs: update API usage examples
|
|
150
|
+
- refactor(core): extract retry logic into helper
|
|
151
|
+
- test: add unit tests for rate limiter
|
|
152
|
+
- chore: update git hooks and repository settings
|
|
153
|
+
- revert: revert "feat(core): introduce streaming API"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Good (包含 Body)**
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
feat(auth): add OAuth2 login flow
|
|
160
|
+
|
|
161
|
+
- implement Google and GitHub third-party login
|
|
162
|
+
- add user authorization callback handling
|
|
163
|
+
- improve login state persistence logic
|
|
164
|
+
|
|
165
|
+
Closes #42
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
```text
|
|
169
|
+
fix(ui): fix button spacing on mobile devices
|
|
170
|
+
|
|
171
|
+
- adjust button padding to fit small screens
|
|
172
|
+
- fix styling issues on iOS Safari
|
|
173
|
+
- optimize touch target size
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Good (包含 BREAKING CHANGE)**
|
|
177
|
+
|
|
178
|
+
```text
|
|
179
|
+
feat(api)!: redesign authentication API
|
|
180
|
+
|
|
181
|
+
- migrate from session-based to JWT authentication
|
|
182
|
+
- update all endpoint signatures
|
|
183
|
+
- remove deprecated login methods
|
|
184
|
+
|
|
185
|
+
BREAKING CHANGE: authentication API has been completely redesigned, all clients must update their integration
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Split Example**
|
|
189
|
+
|
|
190
|
+
```text
|
|
191
|
+
- `feat(types): add new type defs for payment method`
|
|
192
|
+
- `docs: update API docs for new types`
|
|
193
|
+
- `test: add unit tests for payment types`
|
|
194
|
+
- `fix: address linter warnings in new files` ←(如你的仓库有钩子报错)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Important Notes
|
|
200
|
+
|
|
201
|
+
- **仅使用 Git**:不调用任何包管理器/构建命令(无 `pnpm`/`npm`/`yarn` 等)。
|
|
202
|
+
- **尊重钩子**:默认执行本地 Git 钩子;使用 `--no-verify` 可跳过。
|
|
203
|
+
- **不改源码内容**:命令只读写 `.git/COMMIT_EDITMSG` 与暂存区;不会直接编辑工作区文件。
|
|
204
|
+
- **安全提示**:在 rebase/merge 冲突、detached HEAD 等状态下会先提示处理/确认再继续。
|
|
205
|
+
- **可审可控**:如开启 `confirm: true`,每个实际 `git add`/`git commit` 步骤都会进行二次确认。
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 交互式回滚 Git 分支到历史版本;列分支、列版本、二次确认后执行 reset / revert
|
|
3
|
+
allowed-tools: Read(**), Exec(git fetch, git branch, git tag, git log, git reflog, git checkout, git reset, git revert, git switch), Write()
|
|
4
|
+
argument-hint: [--branch <branch>] [--target <rev>] [--mode reset|revert] [--depth <n>] [--dry-run] [--yes]
|
|
5
|
+
# examples:
|
|
6
|
+
# - /git-rollback # 全交互模式,dry‑run
|
|
7
|
+
# - /git-rollback --branch dev # 直接选 dev,其他交互
|
|
8
|
+
# - /git-rollback --branch dev --target v1.2.0 --mode reset --yes
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Claude Command: Git Rollback
|
|
12
|
+
|
|
13
|
+
**目的**:安全、可视地将指定分支回滚到旧版本。
|
|
14
|
+
默认处于 **只读预览 (`--dry-run`)**;真正执行需加 `--yes` 或在交互中确认。
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# 纯交互:列出分支 → 选分支 → 列最近 20 个版本 → 选目标 → 选择 reset 或 revert → 二次确认
|
|
22
|
+
/git-rollback
|
|
23
|
+
|
|
24
|
+
# 指定分支,其他交互
|
|
25
|
+
/git-rollback --branch feature/calculator
|
|
26
|
+
|
|
27
|
+
# 指定分支与目标 commit,并用 hard‑reset 一键执行(危险)
|
|
28
|
+
/git-rollback --branch main --target 1a2b3c4d --mode reset --yes
|
|
29
|
+
|
|
30
|
+
# 只想生成 revert 提交(非破坏式回滚),预览即可
|
|
31
|
+
/git-rollback --branch release/v2.1 --target v2.0.5 --mode revert --dry-run
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Options
|
|
35
|
+
|
|
36
|
+
| 选项 | 说明 |
|
|
37
|
+
| ---------------------- | ---------------------------------------------------------------------------------- |
|
|
38
|
+
| `--branch <branch>` | 要回滚的分支;缺省时交互选择。 |
|
|
39
|
+
| `--target <rev>` | 目标版本(commit Hash、Tag、reflog 引用都行);缺省时交互选择近 `--depth` 条记录。 |
|
|
40
|
+
| `--mode reset\|revert` | `reset`:硬回滚历史;`revert`:生成反向提交保持历史完整。默认询问。 |
|
|
41
|
+
| `--depth <n>` | 在交互模式下列出最近 n 个版本(默认 20)。 |
|
|
42
|
+
| `--dry-run` | **默认开启**,只预览即将执行的命令。 |
|
|
43
|
+
| `--yes` | 跳过所有确认直接执行,适合 CI/CD 脚本。 |
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 交互流程
|
|
48
|
+
|
|
49
|
+
1. **同步远端** → `git fetch --all --prune`
|
|
50
|
+
2. **列分支** → `git branch -a`(本地+远端,过滤受保护分支)
|
|
51
|
+
3. **选分支** → 用户输入或传参
|
|
52
|
+
4. **列版本** → `git log --oneline -n <depth>` + `git tag --merged` + `git reflog -n <depth>`
|
|
53
|
+
5. **选目标** → 用户输入 commit hash / tag
|
|
54
|
+
6. **选模式** → `reset` 或 `revert`
|
|
55
|
+
7. **最终确认** (除非 `--yes`)
|
|
56
|
+
8. **执行回滚**
|
|
57
|
+
- `reset`:`git switch <branch> && git reset --hard <target>`
|
|
58
|
+
- `revert`:`git switch <branch> && git revert --no-edit <target>..HEAD`
|
|
59
|
+
9. **推送建议** → 提示是否 `git push --force-with-lease`(reset)或普通 `git push`(revert)
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 安全护栏
|
|
64
|
+
|
|
65
|
+
- **备份**:执行前自动在 reflog 中记录当前 HEAD,可用 `git switch -c backup/<timestamp>` 恢复。
|
|
66
|
+
- **保护分支**:如检测到 `main` / `master` / `production` 等受保护分支且开启 `reset` 模式,将要求额外确认。
|
|
67
|
+
- **--dry-run 默认开启**:防止误操作。
|
|
68
|
+
- **--force 禁止**:不提供 `--force`;如需强推,请手动输入 `git push --force-with-lease`。
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 适用场景示例
|
|
73
|
+
|
|
74
|
+
| 场景 | 调用示例 |
|
|
75
|
+
| ----------------------------------------------- | ---------------------------------------------------------------- |
|
|
76
|
+
| 热修补丁上线后发现 bug,需要回到 Tag `v1.2.0` | `/git-rollback --branch release/v1 --target v1.2.0 --mode reset` |
|
|
77
|
+
| 运维同事误推了 debug 日志提交,需要生成反向提交 | `/git-rollback --branch main --target 3f2e7c9 --mode revert` |
|
|
78
|
+
| 调研历史 bug,引导新人浏览分支历史 | `/git-rollback` (全交互,dry‑run) |
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 注意
|
|
83
|
+
|
|
84
|
+
1. **reset vs revert**
|
|
85
|
+
- **reset** 会改变历史,需要强推并可能影响其他协作者,谨慎使用。
|
|
86
|
+
- **revert** 更安全,生成新提交保留历史,但会增加一次记录。
|
|
87
|
+
2. **嵌入式仓库** 常有大体积二进制文件;回滚前请确保 LFS/子模块状态一致。
|
|
88
|
+
3. 若仓库启用了 CI 强制校验,回滚后可能自动触发流水线;确认管控策略以免误部署旧版本。
|
|
89
|
+
|
|
90
|
+
---
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 管理 Git worktree,在项目平级的 ../.ccjk/项目名/ 目录下创建,支持智能默认、IDE 集成和内容迁移
|
|
3
|
+
allowed-tools: Read(**), Exec(git worktree add, git worktree list, git worktree remove, git worktree prune, git branch, git checkout, git rev-parse, git stash, git cp, detect-ide, open-ide, which, command, basename, dirname)
|
|
4
|
+
argument-hint: <add|list|remove|prune|migrate> [path] [-b <branch>] [-o|--open] [--track] [--guess-remote] [--detach] [--checkout] [--lock] [--migrate-from <source-path>] [--migrate-stash]
|
|
5
|
+
# examples:
|
|
6
|
+
# - /git-worktree add feature-ui # 从 main/master 创建新分支 'feature-ui'
|
|
7
|
+
# - /git-worktree add feature-ui -o # 创建 worktree 并直接用 IDE 打开
|
|
8
|
+
# - /git-worktree add hotfix -b fix/login -o # 创建新分支 'fix/login',路径为 'hotfix'
|
|
9
|
+
# - /git-worktree migrate feature-ui --from main # 将主分支未提交内容迁移到 feature-ui
|
|
10
|
+
# - /git-worktree migrate feature-ui --stash # 将当前 stash 迁移到 feature-ui
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Claude Command: Git Worktree
|
|
14
|
+
|
|
15
|
+
管理 Git worktree,支持智能默认、IDE 集成和内容迁移,使用结构化的 `../.ccjk/项目名/` 路径。
|
|
16
|
+
|
|
17
|
+
直接执行命令并提供简洁结果。
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# 基本操作
|
|
25
|
+
/git-worktree add <path> # 从 main/master 创建名为 <path> 的新分支
|
|
26
|
+
/git-worktree add <path> -b <branch> # 创建指定名称的新分支
|
|
27
|
+
/git-worktree add <path> -o # 创建并直接用 IDE 打开
|
|
28
|
+
/git-worktree list # 显示所有 worktree 状态
|
|
29
|
+
/git-worktree remove <path> # 删除指定的 worktree
|
|
30
|
+
/git-worktree prune # 清理无效 worktree 记录
|
|
31
|
+
|
|
32
|
+
# 内容迁移
|
|
33
|
+
/git-worktree migrate <target> --from <source> # 迁移未提交内容
|
|
34
|
+
/git-worktree migrate <target> --stash # 迁移 stash 内容
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Options
|
|
38
|
+
|
|
39
|
+
| 选项 | 说明 |
|
|
40
|
+
| ------------------ | -------------------------------------------- |
|
|
41
|
+
| `add [<path>]` | 在 `../.ccjk/项目名/<path>` 添加新的 worktree |
|
|
42
|
+
| `migrate <target>` | 迁移内容到指定 worktree |
|
|
43
|
+
| `list` | 列出所有 worktree 及其状态 |
|
|
44
|
+
| `remove <path>` | 删除指定路径的 worktree |
|
|
45
|
+
| `prune` | 清理无效的 worktree 引用 |
|
|
46
|
+
| `-b <branch>` | 创建新分支并检出到 worktree |
|
|
47
|
+
| `-o, --open` | 创建成功后直接用 IDE 打开(跳过询问) |
|
|
48
|
+
| `--from <source>` | 指定迁移源路径(migrate 专用) |
|
|
49
|
+
| `--stash` | 迁移当前 stash 内容(migrate 专用) |
|
|
50
|
+
| `--track` | 设置新分支跟踪对应的远程分支 |
|
|
51
|
+
| `--guess-remote` | 自动猜测远程分支进行跟踪 |
|
|
52
|
+
| `--detach` | 创建分离 HEAD 的 worktree |
|
|
53
|
+
| `--checkout` | 创建后立即检出(默认行为) |
|
|
54
|
+
| `--lock` | 创建后锁定 worktree |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## What This Command Does
|
|
59
|
+
|
|
60
|
+
1. **环境检查**
|
|
61
|
+
- 通过 `git rev-parse --is-inside-work-tree` 验证 Git 仓库
|
|
62
|
+
- 检测是否在主仓库或现有 worktree 中,进行智能路径计算
|
|
63
|
+
|
|
64
|
+
2. **智能路径管理**
|
|
65
|
+
- 使用 worktree 检测自动从主仓库路径计算项目名
|
|
66
|
+
- 在结构化的 `../.ccjk/项目名/<path>` 目录创建 worktree
|
|
67
|
+
- 正确处理主仓库和 worktree 执行上下文
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# worktree 检测的核心路径计算逻辑
|
|
71
|
+
get_main_repo_path() {
|
|
72
|
+
local git_common_dir=$(git rev-parse --git-common-dir 2>/dev/null)
|
|
73
|
+
local current_toplevel=$(git rev-parse --show-toplevel 2>/dev/null)
|
|
74
|
+
|
|
75
|
+
# 检测是否在 worktree 中
|
|
76
|
+
if [[ "$git_common_dir" != "$current_toplevel/.git" ]]; then
|
|
77
|
+
# 在 worktree 中,从 git-common-dir 推导主仓库路径
|
|
78
|
+
dirname "$git_common_dir"
|
|
79
|
+
else
|
|
80
|
+
# 在主仓库中
|
|
81
|
+
echo "$current_toplevel"
|
|
82
|
+
fi
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
MAIN_REPO_PATH=$(get_main_repo_path)
|
|
86
|
+
PROJECT_NAME=$(basename "$MAIN_REPO_PATH")
|
|
87
|
+
WORKTREE_BASE="$MAIN_REPO_PATH/../.ccjk/$PROJECT_NAME"
|
|
88
|
+
|
|
89
|
+
# 始终使用绝对路径防止嵌套问题
|
|
90
|
+
ABSOLUTE_WORKTREE_PATH="$WORKTREE_BASE/<path>"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**关键修复**: 在现有 worktree 内创建新 worktree 时,始终使用绝对路径以防止出现类似 `../.ccjk/project/.ccjk/project/path` 的路径嵌套问题。
|
|
94
|
+
|
|
95
|
+
3. **Worktree 操作**
|
|
96
|
+
- **add**: 使用智能分支/路径默认创建新 worktree
|
|
97
|
+
- **list**: 显示所有 worktree 的分支和状态
|
|
98
|
+
- **remove**: 安全删除 worktree 并清理引用
|
|
99
|
+
- **prune**: 清理孤立的 worktree 记录
|
|
100
|
+
|
|
101
|
+
4. **智能默认**
|
|
102
|
+
- **分支创建**: 未指定 `-b` 时,使用路径名创建新分支
|
|
103
|
+
- **基础分支**: 新分支从 main/master 分支创建
|
|
104
|
+
- **路径解析**: 未指定路径时使用分支名作为路径
|
|
105
|
+
- **IDE 集成**: 自动检测并提示 IDE 打开
|
|
106
|
+
|
|
107
|
+
5. **内容迁移**
|
|
108
|
+
- 在 worktree 之间迁移未提交改动
|
|
109
|
+
- 将 stash 内容应用到目标 worktree
|
|
110
|
+
- 安全检查防止冲突
|
|
111
|
+
|
|
112
|
+
6. **安全特性**
|
|
113
|
+
- **路径冲突防护**: 创建前检查目录是否已存在
|
|
114
|
+
- **分支检出验证**: 确保分支未被其他地方使用
|
|
115
|
+
- **绝对路径强制**: 防止在 worktree 内创建嵌套的 `.ccjk` 目录
|
|
116
|
+
- **删除时自动清理**: 同时清理目录和 git 引用
|
|
117
|
+
- **清晰的状态报告**: 显示 worktree 位置和分支状态
|
|
118
|
+
|
|
119
|
+
7. **环境文件处理**
|
|
120
|
+
- **自动检测**: 扫描 `.gitignore` 文件中的环境变量文件模式
|
|
121
|
+
- **智能复制**: 复制 `.gitignore` 中列出的 `.env` 和 `.env.*` 文件
|
|
122
|
+
- **排除逻辑**: 跳过 `.env.example` 等模板文件
|
|
123
|
+
- **权限保护**: 保持原始文件权限和时间戳
|
|
124
|
+
- **用户反馈**: 提供已复制环境文件的清晰状态信息
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# 环境文件复制实现
|
|
128
|
+
copy_environment_files() {
|
|
129
|
+
local main_repo="$MAIN_REPO_PATH"
|
|
130
|
+
local target_worktree="$ABSOLUTE_WORKTREE_PATH"
|
|
131
|
+
local gitignore_file="$main_repo/.gitignore"
|
|
132
|
+
|
|
133
|
+
# 检查 .gitignore 是否存在
|
|
134
|
+
if [[ ! -f "$gitignore_file" ]]; then
|
|
135
|
+
return 0
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
local copied_count=0
|
|
139
|
+
|
|
140
|
+
# 检测 .env 文件
|
|
141
|
+
if [[ -f "$main_repo/.env" ]] && grep -q "^\.env$" "$gitignore_file"; then
|
|
142
|
+
cp "$main_repo/.env" "$target_worktree/.env"
|
|
143
|
+
echo "✅ 已复制 .env"
|
|
144
|
+
((copied_count++))
|
|
145
|
+
fi
|
|
146
|
+
|
|
147
|
+
# 检测 .env.* 模式文件(排除 .env.example)
|
|
148
|
+
for env_file in "$main_repo"/.env.*; do
|
|
149
|
+
if [[ -f "$env_file" ]] && [[ "$(basename "$env_file")" != ".env.example" ]]; then
|
|
150
|
+
local filename=$(basename "$env_file")
|
|
151
|
+
if grep -q "^\.env\.\*$" "$gitignore_file"; then
|
|
152
|
+
cp "$env_file" "$target_worktree/$filename"
|
|
153
|
+
echo "✅ 已复制 $filename"
|
|
154
|
+
((copied_count++))
|
|
155
|
+
fi
|
|
156
|
+
fi
|
|
157
|
+
done
|
|
158
|
+
|
|
159
|
+
if [[ $copied_count -gt 0 ]]; then
|
|
160
|
+
echo "📋 已从 .gitignore 复制 $copied_count 个环境文件"
|
|
161
|
+
fi
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Enhanced Features
|
|
168
|
+
|
|
169
|
+
### IDE 集成
|
|
170
|
+
|
|
171
|
+
- **自动检测**: VS Code → Cursor → WebStorm → Sublime Text → Vim
|
|
172
|
+
- **智能提示**: 创建 worktree 后询问是否在 IDE 中打开
|
|
173
|
+
- **直接打开**: 使用 `-o` 标志跳过提示直接打开
|
|
174
|
+
- **自定义配置**: 通过 git config 配置
|
|
175
|
+
|
|
176
|
+
### 内容迁移系统
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# 迁移未提交改动
|
|
180
|
+
/git-worktree migrate feature-ui --from main
|
|
181
|
+
/git-worktree migrate hotfix --from ../other-worktree
|
|
182
|
+
|
|
183
|
+
# 迁移 stash 内容
|
|
184
|
+
/git-worktree migrate feature-ui --stash
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**迁移流程**:
|
|
188
|
+
|
|
189
|
+
1. 验证源有未提交内容
|
|
190
|
+
2. 确保目标 worktree 干净
|
|
191
|
+
3. 显示即将迁移的改动
|
|
192
|
+
4. 使用 git 命令安全迁移
|
|
193
|
+
5. 确认结果并建议后续步骤
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Examples
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# 基本用法
|
|
201
|
+
/git-worktree add feature-ui # 从 main/master 创建新分支 'feature-ui'
|
|
202
|
+
/git-worktree add feature-ui -b my-feature # 创建新分支 'my-feature',路径为 'feature-ui'
|
|
203
|
+
/git-worktree add feature-ui -o # 创建并直接用 IDE 打开
|
|
204
|
+
|
|
205
|
+
# 内容迁移场景
|
|
206
|
+
/git-worktree add feature-ui -b feature/new-ui # 创建新功能 worktree
|
|
207
|
+
/git-worktree migrate feature-ui --from main # 迁移未提交改动
|
|
208
|
+
/git-worktree migrate hotfix --stash # 迁移 stash 内容
|
|
209
|
+
|
|
210
|
+
# 管理操作
|
|
211
|
+
/git-worktree list # 查看所有 worktree
|
|
212
|
+
/git-worktree remove feature-ui # 删除不需要的 worktree
|
|
213
|
+
/git-worktree prune # 清理无效引用
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**示例输出**:
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
✅ Worktree created at ../.ccjk/项目名/feature-ui
|
|
220
|
+
✅ 已复制 .env
|
|
221
|
+
✅ 已复制 .env.local
|
|
222
|
+
📋 已从 .gitignore 复制 2 个环境文件
|
|
223
|
+
🖥️ 是否在 IDE 中打开 ../.ccjk/项目名/feature-ui?[y/n]: y
|
|
224
|
+
🚀 正在用 VS Code 打开 ../.ccjk/项目名/feature-ui...
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Directory Structure
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
parent-directory/
|
|
233
|
+
├── your-project/ # 主项目
|
|
234
|
+
│ ├── .git/
|
|
235
|
+
│ └── src/
|
|
236
|
+
└── .ccjk/ # worktree 管理
|
|
237
|
+
└── your-project/ # 项目 worktree
|
|
238
|
+
├── feature-ui/ # 功能分支
|
|
239
|
+
├── hotfix/ # 修复分支
|
|
240
|
+
└── debug/ # 调试 worktree
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Configuration
|
|
246
|
+
|
|
247
|
+
### IDE 配置
|
|
248
|
+
|
|
249
|
+
- 支持 VS Code、Cursor、WebStorm、Sublime Text、Vim
|
|
250
|
+
- 通过 git config 配置自定义 IDE
|
|
251
|
+
- 基于优先级的自动检测选择
|
|
252
|
+
|
|
253
|
+
### 自定义 IDE 设置
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# 配置自定义 IDE
|
|
257
|
+
git config worktree.ide.custom.sublime "subl %s"
|
|
258
|
+
git config worktree.ide.preferred "sublime"
|
|
259
|
+
|
|
260
|
+
# 控制自动检测
|
|
261
|
+
git config worktree.ide.autodetect true # 默认
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Notes
|
|
267
|
+
|
|
268
|
+
- **性能**: worktree 共享 `.git` 目录,节省磁盘空间
|
|
269
|
+
- **安全**: 路径冲突防护和分支检出验证
|
|
270
|
+
- **迁移**: 仅限未提交改动;已提交内容需使用 `git cherry-pick`
|
|
271
|
+
- **IDE 要求**: 命令行工具必须在 PATH 中
|
|
272
|
+
- **跨平台**: 支持 Windows、macOS、Linux
|
|
273
|
+
- **环境文件**: 自动复制 `.gitignore` 中列出的环境文件到新 worktree
|
|
274
|
+
- **文件排除**: 模板文件如 `.env.example` 仅保留在主仓库中
|
|
275
|
+
|
|
276
|
+
---
|