reimplement-branch

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Reimplement Branch

重新实现分支

Create a new branch with a clean, narrative-quality commit history from an existing branch's changes.
基于现有分支的变更,创建一个拥有清晰、具备叙事性提交历史的新分支。

Context

背景信息

  • Source branch: !
    git branch --show-current
  • Git status: !
    git status --short
  • Commits since main: !
    git log main..HEAD --oneline
  • Full diff against main: !
    git diff main...HEAD --stat
  • 源分支:!
    git branch --show-current
  • Git状态:!
    git status --short
  • 相对于main分支的提交:!
    git log main..HEAD --oneline
  • 与main分支的完整差异统计:!
    git diff main...HEAD --stat

Workflow

工作流程

1. Validate source branch

1. 验证源分支

  • Ensure no uncommitted changes or merge conflicts
  • Confirm branch is up to date with
    main
  • 确保没有未提交的变更或合并冲突
  • 确认分支已与
    main
    分支同步

2. Analyze the diff

2. 分析差异

Study all changes between source branch and
main
. Form a clear understanding of the final intended state.
研究源分支与
main
分支之间的所有变更,清晰理解最终预期状态。

3. Create clean branch

3. 创建干净分支

bash
git checkout main
git checkout -b <new-branch-name>
Use the user-provided branch name, or
{source-branch}-clean
if none provided.
bash
git checkout main
git checkout -b <new-branch-name>
使用用户提供的分支名称,若未提供则使用
{source-branch}-clean

4. Plan commit storyline

4. 规划提交主线

Break the implementation into self-contained logical steps. Each step should reflect a stage of development—as if writing a tutorial.
将实现过程拆分为逻辑独立的步骤。每个步骤应反映开发的一个阶段——就像编写教程一样。

5. Reimplement the work

5. 重新实现工作

Recreate changes in the clean branch, committing step by step. Each commit must:
  • Introduce a single coherent idea
  • Include a clear commit message and description
Use
git commit --no-verify
for intermediate commits.
Pre-commit hooks check tests, types, and imports that may not pass until full implementation is complete.
在干净分支中重新创建变更,逐步提交。每个提交必须:
  • 仅引入一个连贯的功能点
  • 包含清晰的提交信息和描述
中间提交使用
git commit --no-verify
。预提交钩子会检查测试、类型和导入,这些检查可能在完整实现完成前无法通过。

6. Verify correctness

6. 验证正确性

  • Confirm final state exactly matches source branch:
    git diff <source-branch>
  • Run final commit without
    --no-verify
    to ensure all checks pass
  • 确认最终状态与源分支完全一致:
    git diff <source-branch>
  • 最终提交不使用
    --no-verify
    ,确保所有检查通过

7. Open PR

7. 发起PR

Use the
/pr
skill to create a pull request. Include a link to the original branch in the PR description.
使用
/pr
技能创建拉取请求。在PR描述中包含指向原分支的链接。

Rules

规则

  • Never add yourself as author or contributor
  • Never include "Generated with Claude Code" or "Co-Authored-By" lines
  • End state of clean branch must be identical to source branch
  • 切勿将自己添加为作者或贡献者
  • 切勿包含“Generated with Claude Code”或“Co-Authored-By”行
  • 干净分支的最终状态必须与源分支完全一致