rebase-assistant
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRebase assistant
Rebase助手
Goal
目标
Rebase the current branch onto a target branch safely, with built-in conflict resolution guidance.
安全地将当前分支变基到目标分支,内置冲突解决指南。
Inputs to confirm (ask if missing)
待确认的输入项(缺失时请询问用户)
- Target branch (explicit branch name or "default branch").
- Preferred conflict bias when ambiguous: keep ours, keep theirs, or manual merge.
- Protected paths or file types to avoid touching.
- 目标分支(明确的分支名称或「默认分支」)。
- 歧义场景下的优先冲突处理倾向:保留我方改动、保留对方改动,或手动合并。
- 需要避免改动的受保护路径或文件类型。
Workflow
工作流程
- Identify the target branch
- If user says "default branch": discover via (read "HEAD branch").
git remote show origin - If ambiguous or no remote: ask the user which branch to use.
- If user says "default branch": discover via
- Preflight checks
- (must be clean before rebase).
git status -sb - to sync remotes.
git fetch --prune - Optional safety branch (ask before creating): .
git branch backup/<current-branch>
- Start the rebase
git rebase <target-branch>
- If conflicts occur, resolve (repeat per file)
- Inspect conflict list:
git status -sbgit diff --name-only --diff-filter=U
- Classify and inspect:
- Content conflicts: open file, resolve markers.
- Delete/modify or rename conflicts: decide keep vs delete explicitly.
- Binary conflicts: choose ours/theirs only.
- Show base/ours/theirs when useful:
git show :1:<path>git show :2:<path>git show :3:<path>
- File-level choice when safe:
git checkout --ours <path>git checkout --theirs <path>
- Stage resolved files:
git add <path> - Continue:
git rebase --continue
- Inspect conflict list:
- Finish and verify
- Ensure no conflicts:
git status -sb - Suggest a fast test/build if available.
- Ensure no conflicts:
- 确定目标分支
- 如果用户提到「默认分支」:通过查询(读取「HEAD branch」字段)。
git remote show origin - 如果存在歧义或没有远程仓库:询问用户需要使用的分支。
- 如果用户提到「默认分支」:通过
- 预检
- 执行(变基前必须保证工作区干净)。
git status -sb - 执行同步远程仓库信息。
git fetch --prune - 可选的安全备份分支(创建前需询问用户):。
git branch backup/<current-branch>
- 执行
- 启动变基
git rebase <target-branch>
- 出现冲突时进行解决(每个文件重复以下步骤)
- 查看冲突列表:
git status -sbgit diff --name-only --diff-filter=U
- 分类检查冲突:
- 内容冲突:打开文件,解决冲突标记。
- 删除/修改或重命名冲突:明确决定保留还是删除。
- 二进制文件冲突:仅可选择保留我方/对方版本。
- 必要时展示基础版本/我方版本/对方版本:
git show :1:<path>git show :2:<path>git show :3:<path>
- 安全场景下可进行文件级选择:
git checkout --ours <path>git checkout --theirs <path>
- 暂存已解决的文件:
git add <path> - 继续变基:
git rebase --continue
- 查看冲突列表:
- 完成并验证
- 执行确保无冲突。
git status -sb - 若有可用的测试/构建流程,建议快速运行验证。
- 执行
Safety rules
安全规则
- Never run ,
git reset --hard, orgit clean -fdunless the user explicitly requests it.git rebase --abort - Always show candidate commands before applying destructive changes.
- 除非用户明确要求,否则永远不要执行、
git reset --hard或git clean -fd命令。git rebase --abort - 执行破坏性改动前必须先展示待执行的候选命令。
Deliverables
交付物
- The exact rebase command used and target branch.
- Conflict list grouped by type with per-file resolution guidance.
- Completion command and a short verification suggestion.
- 实际使用的变基命令和目标分支。
- 按类型分组的冲突列表,以及每个文件的解决指南。
- 完成命令和简短的验证建议。