变基
- 作者仓库星标 2,380
- 许可证 MIT
- 作者仓库 dotfiles
- 领域
- 工程开发
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 94 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @ryanb · MIT
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 命令执行
- 网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
步骤1:确定基础分支
按以下顺序确定基础分支: 如果用户指定分支,则使用 `$ARGUMENTS` 如果脚本存在且可执行,则使用 `bin/base-branch` 询问用户要变基到哪个分支
第 2 步:开始变基
获取最新版本并开始变基:如果变基完成且没有冲突,请跳到步骤 6。
第 3 步:解决冲突
使用`git diff --name-only --diff-filter=U` 识别冲突文件 阅读每个冲突文件并了解冲突的双方 通过考虑双方的情况来解决冲突 — 不要盲目地选择一方。了解每个更改的意图并产生正确合并两者的结果。使用`git add`暂存已解决的文件如果冲突不明确并且您无法自信地确定正确的解决方案,请询问用户。
第四步:运行相关测试
运行与有冲突的文件相关的测试。如果测试由于冲突解决而失败,请在继续之前修复它们。如果测试失败但看起来与变基无关,请通过存储和测试进行验证:如果在没有进行更改的情况下测试也失败,则失败是预先存在的。请用户注意这一点并继续。如果测试仅因您的更改而失败,则变基引入了问题。调查并修复。
第 5 步:继续变基
如果还有更多冲突,请返回步骤 3。重复直至变基完成。
第6步:检查遥控器并比较
检查远程跟踪分支是否存在:如果远程分支存在,请运行`/remote-diff`技能将变基结果与远程进行比较,并标记任何潜在问题。如果不存在远程分支,则跳过此步骤并报告变基已完成。
# Rebase
Rebase the current branch onto a base branch, resolving conflicts and verifying tests along the way.
## Step 1: Determine base branch
Determine the base branch in this order:
1. Use `$ARGUMENTS` if the user specifies a branch
2. Use `bin/base-branch` if the script exists and is executable
3. Ask the user which branch to rebase onto
## Step 2: Start the rebase
Fetch latest and begin the rebase:
```bash
git fetch origin
git rebase origin/<base-branch>
```
If the rebase completes with no conflicts, skip to Step 6.
## Step 3: Resolve conflicts
1. Identify the conflicting files with `git diff --name-only --diff-filter=U`
2. Read each conflicting file and understand both sides of the conflict
3. Resolve the conflict by taking both sides into account — don't blindly pick one side. Understand the intent of each change and produce a result that incorporates both correctly.
4. Stage the resolved files with `git add`
If a conflict is ambiguous and you can't confidently determine the correct resolution, ask the user.
## Step 4: Run related tests
Run the tests related to the files that had conflicts. If tests fail due to the conflict resolution, fix them before proceeding.
If tests fail but seem **unrelated** to the rebase, verify by stashing and testing:
```bash
git stash
# run tests again
git stash pop
```
- If tests also fail without your changes, the failures are pre-existing. Note this for the user and continue.
- If tests only fail with your changes, the rebase introduced the problem. Investigate and fix.
If you are unable to resolve test failures, let the user know what's broken and what you tried.
## Step 5: Continue the rebase
```bash
git rebase --continue
```
If there are more conflicts, go back to Step 3. Repeat until the rebase is complete.
## Step 6: Check remote and compare
Check if a remote tracking branch exists:
```bash
git rev-parse --verify @{u} 2>/dev/null
```
If a remote branch exists, run the `/remote-diff` skill to compare the rebase result against the remote and flag any potential issues.
If no remote branch exists, skip this step and report that the rebase is complete.
章节与文件索引
按说明文件中的顺序排列。
步骤1:确定基础分支
第 2 步:开始变基
第 3 步:解决冲突
第四步:运行相关测试
第 5 步:继续变基
文件/命令 -> $ARGUMENTS · bin/base-branch · git diff --name-only --diff-filter=U · git add · /remote-diff
内容校验值 -> 8a5cdd456604
当前原文的自动摘译,尚未人工审校。
第 3 步:解决冲突
使用
git diff --name-only --diff-filter=U识别冲突文件 阅读每个冲突文件并了解冲突的双方 通过考虑双方的情况来解决冲突 — 不要盲目地选择一方。了解每个更改的意图并产生正确合并两者的结果。使用git add暂存已解决的文件如果冲突不明确并且您无法自信地确定正确的解决方案,请询问用户。