gh-stackx
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesegh-stackx
gh-stackx
Use the extension to manage stacked pull requests on repositories that do not have the private-preview GitHub Stacked PRs API.
gh-stackxgh使用这个扩展,在不支持GitHub Stacked PRs API私有预览版的仓库上管理stacked pull requests。
gh-stackxghWhen to use
使用场景
- You want to open a series of dependent PRs.
- fails with
gh stack submit.⚠ Stacked PRs are not enabled for this repository - You need to keep PR bases correct as the stack is rebased or merged.
- You want to merge a stack from the top down without manually editing PR bases.
- 你需要创建一系列相互依赖的PR。
- 执行失败并提示
gh stack submit。⚠ Stacked PRs are not enabled for this repository - 当堆叠分支被变基或合并时,你需要保持PR的基准分支正确。
- 你希望从上到下合并整个堆叠分支,而无需手动编辑PR的基准分支。
Prerequisites
前置条件
-
CLI installed and authenticated.
gh -
extension installed for local stack operations:
github/gh-stackbashgh extension install github/gh-stack -
installed:
gh-stackxbashgh extension install ThePlenkov/gh-stackx
-
已安装并完成认证的CLI。
gh -
已安装用于本地堆叠操作的扩展:
github/gh-stackbashgh extension install github/gh-stack -
已安装:
gh-stackxbashgh extension install ThePlenkov/gh-stackx
Core concepts
核心概念
- Trunk — the base branch, usually .
main - Stack — an ordered list of branches where each branch builds on the previous one.
- Bottom — the branch closest to trunk.
- Top — the branch farthest from trunk.
- Base — the parent branch for a PR. The bottom layer uses trunk; every other layer uses the previous branch.
- Trunk — 基准分支,通常为。
main - Stack — 有序的分支列表,每个分支都基于前一个分支构建。
- Bottom — 最接近Trunk的分支。
- Top — 离Trunk最远的分支。
- Base — PR的父分支。最底层分支使用Trunk;其他所有层都使用前一个分支作为基准。
Workflow
工作流程
Create a stack
创建堆叠分支
bash
git checkout main
git pull origin main
gh stackx init feature/authbash
git checkout main
git pull origin main
gh stackx init feature/authwork and commit
进行开发并提交
gh stackx add feature/api
gh stackx add feature/api
work and commit
进行开发并提交
gh stackx add feature/ui
gh stackx add feature/ui
work and commit
进行开发并提交
undefinedundefinedSubmit PRs
提交PR
bash
gh stackx submit # drafts
gh stackx submit --opensubmit--base--headbash
gh stackx submit # 草稿状态
gh stackx submit --opensubmit--base--headSync after trunk or parent PR changes
主干或父PR变更后同步
bash
gh stackx sync
gh stackx sync --remote upstreamsyncgh stack syncgh pr edit --basebash
gh stackx sync
gh stackx sync --remote upstreamsyncgh stack syncgh pr edit --baseMerge top-down
从上到下合并
bash
gh stackx merge
gh stackx merge --squash
gh stackx merge --rebasemergegh pr mergebash
gh stackx merge
gh stackx merge --squash
gh stackx merge --rebasemergegh pr mergeLocal navigation
本地导航
These pass through to :
github/gh-stackbash
gh stackx view --json
gh stackx up
gh stackx down
gh stackx top
gh stackx bottom
gh stackx trunk以下命令会直接调用:
github/gh-stackbash
gh stackx view --json
gh stackx up
gh stackx down
gh stackx top
gh stackx bottom
gh stackx trunkImportant rules
重要规则
- Keep the working tree clean before or
sync; rebase operations fail on uncommitted changes.merge - Create PRs bottom-up so each base exists before the child PR is opened.
- Merge top-down so dependent PRs are merged before their parents move.
- Do not commit . It is local metadata.
.git/gh-stack
- 在执行或
sync前保持工作树干净;未提交的变更会导致变基操作失败。merge - 从下到上创建PR,确保每个子PR打开前其基准分支已存在。
- 从上到下合并PR,确保依赖PR在其父分支合并前完成合并。
- 不要提交文件,它是本地元数据。
.git/gh-stack
Troubleshooting
故障排查
- fails: ensure
gh stackx viewis installed.github/gh-stack - A PR has the wrong base: run .
gh stackx sync - or
submitstops with errors: fix the underlyingmergeissue, then re-run.gh pr
- 执行失败:确保已安装
gh stackx view扩展。github/gh-stack - PR的基准分支错误:执行。
gh stackx sync - 或
submit命令因错误停止:修复底层的merge问题,然后重新执行命令。gh pr
Install this skill
安装该Skill
With (Vercel skills):
npx skillsbash
npx skills add ThePlenkov/gh-stackx --skill gh-stackxWith (CodeBuddy):
npx skillbash
SKILL_BASE_URL=https://github.com/ThePlenkov/gh-stackx/tree/main npx skill skills/gh-stackx使用(Vercel skills):
npx skillsbash
npx skills add ThePlenkov/gh-stackx --skill gh-stackx使用(CodeBuddy):
npx skillbash
SKILL_BASE_URL=https://github.com/ThePlenkov/gh-stackx/tree/main npx skill skills/gh-stackxFurther reading
更多阅读
The full workflow is already inline above. For more, see the repository:
- Usage guide — practical walkthrough with examples.
- Stacked PR methodology — why and how stacked PRs work.
- Specification — full command and architecture specification.
- REVIEW.md — review policy for this repository.
- AGENTS.md — how to work on this repository.