4.4 KiB
name, description
| name | description |
|---|---|
| publishing-git-branches | 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. |
Publishing Git Branches
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.
Hard Stop: Rebase Conflict
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.
Workflow
- 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. - Run
git fetch origin main. Do not usegit pullto update the branch. - Rebase the current branch onto the fetched
origin/mainwithgit rebase origin/main. - If the rebase has any conflict, apply the hard stop above.
- Push the current branch to
origin. If rebasing rewrote a branch already on the remote, update it only withgit push --force-with-lease origin HEAD. Never use plain--force. - Create a PR with the current branch as head and remote
mainas base. Use the repository's configured PR tooling, write its title and body in Chinese, and report its URL.
Naming And PR Language
When a branch needs a new name, use <type>/<short-kebab-topic>. Choose the
type for the actual change:
| Type | Use for |
|---|---|
feat |
新功能或用户可见能力 |
fix |
缺陷修复 |
chore |
维护、工具或流程变更 |
docs |
文档变更 |
refactor |
不改变预期行为的重构 |
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.
Invariants
- Do not fast-forward, merge, or push the current branch into local or remote
main; changes reachmainonly 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:orfix:; 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.
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 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
git fetch origin main
git rebase origin/main
git push origin HEAD
# if the rebased branch already exists on origin:
git push --force-with-lease origin HEAD
# PR 标题和正文使用中文;标题必须以 `feat:`、`fix:` 或 `chore:` 等类型前缀开头
gh pr create --base main --head "$(git branch --show-current)" \
--title "<type>: <中文标题>" \
--body "<中文正文:改动、验证、风险或后续事项>"
Do not run the force-with-lease command after a successful ordinary push.
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.