rebase
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRebase
Rebase
Rebase the current branch onto the latest .
origin/main将当前分支Rebase到最新的分支。
origin/mainUsage
使用场景
When asked to rebase:
-
Check current state:bash
git status git branch --show-current- If on , warn the user and stop — rebasing main onto itself is a no-op
main - If there are uncommitted changes, warn the user and stop — do NOT stash automatically
- If on
-
Fetch latest:bash
git fetch origin -
Rebase onto main:bash
git rebase origin/main -
Handle conflicts:
- If the rebase succeeds cleanly, proceed to step 5
- If there are conflicts:
- List the conflicting files
- Ask the user how they want to proceed: resolve manually, or abort
- Do NOT force-continue or blindly resolve conflicts
- To abort:
git rebase --abort
-
Confirm — Print a summary:text
Rebased feat/123-add-watch-mode onto origin/main- Do NOT push automatically
- If the user explicitly asks to push, use
git push --force-with-lease - NEVER use — always
--forcefor safety--force-with-lease
当需要执行Rebase操作时:
-
检查当前状态:bash
git status git branch --show-current- 如果当前在分支,警告用户并停止——将main分支Rebase到自身无意义
main - 如果存在未提交的变更,警告用户并停止——不要自动执行stash
- 如果当前在
-
拉取最新代码:bash
git fetch origin -
Rebase到main分支:bash
git rebase origin/main -
处理冲突:
- 如果Rebase顺利完成,进入步骤5
- 如果存在冲突:
- 列出冲突文件
- 询问用户如何处理:手动解决,还是终止Rebase
- 不要强制继续或盲目解决冲突
- 终止命令:
git rebase --abort
-
确认操作 —— 打印总结信息:text
Rebased feat/123-add-watch-mode onto origin/main- 不要自动推送
- 如果用户明确要求推送,使用
git push --force-with-lease - 绝对不要使用—— 为了安全,始终使用
--force--force-with-lease
Important
注意事项
- NEVER rebase itself
main - NEVER use — always
git push --force--force-with-lease - NEVER stash or discard uncommitted changes — warn and stop
- NEVER use or
--no-editflags with rebase-i - If conflicts occur, always involve the user — never auto-resolve
- 绝对不要Rebase分支本身
main - 绝对不要使用—— 始终使用
git push --force--force-with-lease - 绝对不要stash或丢弃未提交的变更 —— 警告用户并停止
- 绝对不要在Rebase时使用或
--no-edit参数-i - 如果发生冲突,务必让用户参与处理——绝不自动解决冲突