chore: 中文化发布 Git 分支 skill

This commit is contained in:
YBF
2026-09-17 12:06:24 +08:00
parent 784bbec2a0
commit b0197aad0c
2 changed files with 41 additions and 61 deletions
+39 -59
View File
@@ -1,45 +1,36 @@
---
name: publishing-git-branches
description: Use when preparing the current Git feature branch for a pull request to origin/main, especially when its name, remote state, or base may be stale.
description: 准备当前 Git 功能分支并向 origin/main 创建 PR;用于需要按任务或实际改动强制规范分支名称、同步基线及发布变更时。
---
# Publishing Git Branches
# 发布 Git 分支
Prepare the current branch for review without bypassing the PR path. Keep `main`
unchanged locally and remotely; only the PR may carry the branch's commits into
`main`.
在不绕过 PR 流程的前提下,将当前分支准备为可评审状态。保持本地和远程 `main` 不变;只有 PR 可以将当前分支的提交带入 `main`
## Hard Stop: Rebase Conflict
## 硬停止:rebase 冲突
**Any rebase conflict means stop immediately and ask the user. There are no
exceptions for a one-line, mechanical, generated, obvious, or inferred
conflict.** Do not modify a conflicted file, stage it, continue, abort, or run
another Git command intended to move the rebase forward. Report the conflict
paths and wait for an explicit next instruction.
**发生任何 rebase 冲突都必须立刻停止并询问用户。单行、机械生成、看似明显或可以推断的冲突都没有例外。** 不要修改冲突文件、暂存、继续、终止,或执行其他推进 rebase 的 Git 命令。报告冲突路径并等待明确的下一步指令。
## Workflow
## 工作流程
1. Inspect the current branch name and its commits/diff relative to `origin/main`.
If the name is clearly about a different change, rename the local branch to a
concise name that reflects the actual changes before pushing. If the old name
already exists remotely, do not delete it unless the user separately asks.
2. Run `git fetch origin main`. Do not use `git pull` to update the branch.
3. Rebase the current branch onto the fetched `origin/main` with `git rebase
origin/main`.
4. If the rebase has any conflict, apply the hard stop above.
5. Push the current branch to `origin`. If rebasing rewrote a branch already on
the remote, update it only with `git push --force-with-lease origin HEAD`.
Never use plain `--force`.
6. Create a PR with the current branch as head and remote `main` as base. Use
the repository's configured PR tooling, write its title and body in Chinese,
and report its URL.
1. 检查当前分支名,以及相对 `origin/main` 的提交和 diff。
2. **在发布前必须确定并落实分支名。** 若当前任务准确覆盖这些改动,按任务命名;否则按当前改动命名。目标名称为 `<type>/<short-kebab-topic>`。当前名称与目标不完全一致时,必须先使用 `git branch -m <目标名称>` 重命名本地分支。若旧名称已存在远程,除非用户另行要求,不要删除它。
3. 运行 `git fetch origin main`;不要用 `git pull` 更新分支。
4. 使用 `git rebase origin/main` 将当前分支 rebase 到刚获取的 `origin/main`
5. 如果 rebase 有任何冲突,执行上述硬停止规则。
6. 将当前分支推送到 `origin`。如果 rebase 改写了远程已有的当前分支,只能使用 `git push --force-with-lease origin HEAD` 更新;绝不能使用普通 `--force`
7. 以当前分支为 head、远程 `main` 为 base 创建 PR。使用仓库配置的 PR 工具,标题和正文均使用中文,并报告 PR URL。
## Naming And PR Language
## 分支命名与 PR 文案
When a branch needs a new name, use `<type>/<short-kebab-topic>`. Choose the
type for the actual change:
分支名称必须由当前工作事实得出,不能保留临时名、过时名或与改动无关的名称。先按以下优先级决定 `short-kebab-topic`
| Type | Use for |
1. 存在且准确覆盖当前改动的活跃任务时,使用该任务的简短主题。
2. 没有适用任务,或当前改动超出任务范围时,根据相对 `origin/main` 的实际 diff 和提交生成简短主题。
选择反映实际改动的类型:
| 类型 | 使用场景 |
| --- | --- |
| `feat` | 新功能或用户可见能力 |
| `fix` | 缺陷修复 |
@@ -49,40 +40,31 @@ type for the actual change:
| `test` | 测试覆盖或测试工具变更 |
| `ci` | 持续集成或发布自动化变更 |
Do not rename an existing branch solely to normalize its style; this convention
applies when creating a branch or correcting an obvious semantic mismatch.
这是发布前的强制步骤,而不是仅在名称“明显不匹配”时才执行的风格建议。若当前名称已经精确等于按上述规则得出的目标名称,不必执行无效的同名重命名,但仍须说明名称来自任务还是实际改动,并给出相应证据。
PR title and body must be Chinese. The title must begin with the conventional
type prefix that matches the change, for example `fix: 修复 Chrome 消息回调兼容性`;
its descriptive text must be Chinese. The body must describe the change,
validation, and any risk or follow-up in Chinese.
PR 标题和正文必须为中文。标题必须以匹配实际改动的常规类型前缀开头,例如 `fix: 修复 Chrome 消息回调兼容性`;描述文字使用中文。正文应以中文说明改动、验证以及风险或后续事项。
## Invariants
## 不变量
- Do not fast-forward, merge, or push the current branch into local or remote
`main`; changes reach `main` only through the PR.
- Branch renaming is required only for an obvious semantic mismatch, not a
stylistic preference. State the evidence used to judge the mismatch.
- PR title must use the type prefix that matches the change, such as `feat:` or
`fix:`; the remaining title text and body use Chinese.
- Do not assume permissions for unrelated cleanup, conflict resolution, merging
the PR, deleting a branch, or force-pushing any branch other than the current
rebased branch.
- 不要快进、合并或将当前分支推送进本地或远程 `main`;改动只能经由 PR 进入 `main`
- 每次发布都必须完成分支命名决策:优先依据准确覆盖改动的任务,否则依据实际改动;目标名不同就必须重命名。报告名称来源和判断证据。
- PR 标题必须使用匹配改动的类型前缀,如 `feat:``fix:`;其余标题文字和正文均为中文。
- 不要擅自执行无关清理、冲突解决、合并 PR、删除分支,或对当前 rebase 后分支之外的任何分支强制推送。
## Command Shape
## 命令形态
Use the repository's existing validation steps before push when they are known
or requested. The Git and PR sequence should have this shape:
已知或用户要求时,在推送前运行仓库既有的验证步骤。Git 和 PR 操作应遵循以下形态:
```bash
git branch --show-current
git log --oneline origin/main..HEAD
git diff --stat origin/main...HEAD
# rename with `git branch -m <type>/<short-kebab-topic>` if the name clearly mismatches
# 基于适用任务或当前实际改动,确定 <type>/<short-kebab-topic>;名称不同则必须重命名
git branch -m <type>/<short-kebab-topic>
git fetch origin main
git rebase origin/main
git push origin HEAD
# if the rebased branch already exists on origin:
# rebase 后的当前分支已存在于 origin
git push --force-with-lease origin HEAD
# PR 标题和正文使用中文;标题必须以 `feat:`、`fix:` 或 `chore:` 等类型前缀开头
gh pr create --base main --head "$(git branch --show-current)" \
@@ -90,13 +72,11 @@ gh pr create --base main --head "$(git branch --show-current)" \
--body "<中文正文:改动、验证、风险或后续事项>"
```
Do not run the force-with-lease command after a successful ordinary push.
普通推送成功后,不要再执行 force-with-lease 命令。
## Red Flags
## 红线
-The conflict is trivial” or “I can infer the intended resolution” means
stop and ask; it is still a rebase conflict.
-It is only a typo/urgent fix” does not excuse retaining a clearly mismatched
branch name or bypassing the PR route.
- “A merge is quicker” does not replace the required rebase.
- English PR titles or bodies do not meet this project's PR writing convention.
-冲突很简单”或“我能推断应如何解决”仍意味着停止并询问;它依然是 rebase 冲突。
- “只是拼写错误或紧急修复”不能成为保留临时、过时或与改动不符分支名,也不能绕过 PR 流程的理由。
-merge 更快”不能替代要求的 rebase。
- 英文 PR 标题或正文不符合本项目的 PR 文案约定。
@@ -1,3 +1,3 @@
interface:
display_name: "Publishing Git Branches"
short_description: "Safely rebase a branch and open a main PR"
display_name: "发布 Git 分支"
short_description: "按任务或实际改动命名分支、rebase 并创建 main PR"