重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
graphite by withgraphite/agent-skills
npx skills add https://github.com/withgraphite/agent-skills --skill graphite使用 Graphite (gt) 创建、导航和管理堆叠式拉取请求。
| 我想... | 命令 |
|---|---|
| 创建新分支/PR | gt create branch-name -m "message" |
| 修改当前分支 | gt modify -m "message" |
| 向上导航堆栈 | gt up |
| 向下导航堆栈 | gt down |
| 跳转到堆栈顶部 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
gt top| 跳转到堆栈底部 | gt bottom |
| 查看堆栈结构 | gt ls |
| 提交堆栈以供审核 | gt submit --no-interactive |
| 在主干上重新调整堆栈 | gt restack |
| 更改分支父级 | gt track --parent <branch> |
| 重命名当前分支 | gt rename <new-name> |
| 在堆栈中移动分支 | gt move |
大致按重要性降序排列:
不要担心创建过多的拉取请求。 创建更多的拉取请求总是比创建更少的要好。
没有更改是太小的: 微小的 PR 能让中型/大型的 PR 更加清晰。
只要它们能独立通过构建,请始终支持创建更多的 PR。
为堆栈中的 PR 命名时,请遵循以下语法:
简洁的堆栈功能名称/简洁的更改描述
例如,一个包含 4 个 PR 的堆栈:
auth-bugfix/reorder-args
auth-bugfix/improve-logging
auth-bugfix/improve-documentation
auth-bugfix/handle-401-status-codes
git add <files>gt create branch-name -m "commit message"gt submit --no-interactive在创建分支之前,检查当前分支是否被跟踪:
gt branch info
如果看到 "ERROR: Cannot perform this operation on untracked branch":
选项 A(推荐):临时跟踪,然后重新设置父级
跟踪当前分支:gt track -p main
使用 gt create 正常创建你的堆栈
创建完所有分支后,将你的第一个新分支的父级重新设置到 main:
gt checkout <first-branch-of-your-stack> gt track -p main gt restack
选项 B:暂存更改并从 main 开始
git stashgit checkout main && git pullgit checkout -b temp-working && git stash popgt track -p main 和 gt create# 向上移动一个分支(朝向堆栈顶部)
gt up
# 向下移动一个分支(朝向主干)
gt down
# 跳转到堆栈顶部
gt top
# 跳转到堆栈底部(主干上方的第一个分支)
gt bottom
# 查看完整的堆栈结构
gt ls
git add <files>
gt modify -m "updated commit message"
使用 gt move 来重新排序堆栈中的分支。这比尝试使用 gt create --insert 更简单。
如果你在一个功能分支之上创建了堆栈,但希望它基于 main:
# 转到你堆栈的第一个分支
gt checkout <first-branch>
# 将其父级更改为 main
gt track --parent main
# 重新调整整个堆栈
gt restack
gt rename new-branch-name
如果更改已经提交,但你想以不同的方式重新堆叠它们:
# 重置最后一次提交,保持更改未暂存
git reset HEAD^
# 重置多次提交(例如,最后 2 次提交)
git reset HEAD~2
# 查看差异以了解你正在处理的内容
git diff HEAD
在运行 gt submit 之前,验证第一个 PR 的父级是 main:
gt ls
如果第一个分支的父级不是 main:
gt checkout <first-branch>
gt track -p main
gt restack
创建每个 PR 后,运行适当的代码检查、构建和测试:
gt modifygt submit --no-interactive
提交后,使用 gh pr edit 设置正确的标题和描述。
重要提示: 切勿使用 Bash heredocs 来编写 PR 描述 - shell 转义会破坏 Markdown 表格、代码块等。应该:
Write 工具创建包含完整 Markdown 内容的 /tmp/pr-body.md--body-file 的 gh pr edit:gh pr edit <PR_NUMBER> --title "stack-name: description" --body-file /tmp/pr-body.md
PR 描述必须包括:
示例(用于一个添加警告功能的 3-PR 堆栈中的 PR):
## 堆栈上下文
此堆栈在用户绕过 GitHub 规则集时,在合并按钮上添加警告。
## 为什么?
能够绕过规则集的用户(通过组织管理员或团队成员身份)目前看不到任何表明他们正在规避分支保护的指示。此 PR 将绕过数据从服务器传递到前端,以便前端警告(PR 2)能够显示它。
| 问题 | 解决方案 |
|---|---|
| "Cannot perform this operation on untracked branch" | 首先运行 gt track -p main |
| 堆栈的父级设置错误 | 使用 gt track -p main 然后 gt restack |
| 需要重新排序 PR | 使用 gt move |
| 重新调整堆栈时发生冲突 | 解决冲突,然后 git rebase --continue |
| 想要拆分一个 PR | 重置提交 (git reset HEAD^),有选择地重新暂存,创建新分支 |
| 需要删除一个分支(非交互式) | gt delete <branch> -f -q |
gt restack 遇到无关冲突 | 改用针对性的 git rebase <target>(见下文) |
| 重新调整在冲突中中断 | 检查文件是否已解决但未暂存,然后 git add + git rebase --continue |
在具有许多同级分支的深度嵌套堆栈中,gt restack 可能会出现问题:
git rebase 而不是 gt restack在以下情况下使用直接的 git rebase:
gt restack 在无关分支中遇到冲突# 1. 检出你想要重新调整的分支
git checkout my-feature-branch
# 2. 重新调整到目标分支(例如,更新后的父分支)
git rebase target-branch
# 3. 如果遇到冲突:
# - 在文件中解决冲突
# - 暂存它:git add <file>
# - 继续:git rebase --continue
# 4. 如果一个提交已过时且应该被跳过:
git rebase --skip
# 5. 重新调整后,使用 gt modify 同步 graphite 的跟踪
gt modify --no-edit
如果重新调整被中断(例如,Claude 会话用完了上下文):
检查状态:
git status # 查找 "interactive rebase in progress" 和 "Unmerged paths"
阅读 "unmerged" 文件 - 它们可能已经解决(没有冲突标记)
如果已经解决,只需暂存并继续:
git add <resolved-files> git rebase --continue
如果仍有冲突标记,先解决它们,然后暂存并继续
# 删除一个分支(非交互式,即使未合并)
gt delete branch-to-delete -f -q
# 同时删除所有子分支(上游堆栈)
gt delete branch-to-delete -f -q --upstack
# 同时删除所有祖先分支(下游堆栈)
gt delete branch-to-delete -f -q --downstack
标志:
-f / --force:即使未合并或已关闭也删除-q / --quiet:意味着 --no-interactive,最小化输出删除中间分支后,子分支会自动重新调整到父分支上。如果需要手动更新跟踪:
gt checkout child-branch
gt track --parent new-parent-branch
每周安装次数
71
仓库
GitHub 星标数
1
首次出现
2026年2月19日
安全审计
安装于
codex71
cursor71
gemini-cli70
github-copilot70
kimi-cli70
amp70
Work with Graphite (gt) for creating, navigating, and managing stacked pull requests.
| I want to... | Command |
|---|---|
| Create a new branch/PR | gt create branch-name -m "message" |
| Amend current branch | gt modify -m "message" |
| Navigate up the stack | gt up |
| Navigate down the stack | gt down |
| Jump to top of stack | gt top |
| Jump to bottom of stack | gt bottom |
| View stack structure | gt ls |
| Submit stack for review | gt submit --no-interactive |
| Rebase stack on trunk | gt restack |
| Change branch parent | gt track --parent <branch> |
| Rename current branch | gt rename <new-name> |
| Move branch in stack | gt move |
In roughly descending order of importance:
Do NOT worry about creating TOO MANY pull requests. It is always preferable to create more pull requests than fewer.
NO CHANGE IS TOO SMALL: tiny PRs allow for the medium/larger-sized PRs to have more clarity.
Always argue in favor of creating more PRs, as long as they independently pass build.
When naming PRs in a stack, follow this syntax:
terse-stack-feature-name/terse-description-of-change
For example, a 4 PR stack:
auth-bugfix/reorder-args
auth-bugfix/improve-logging
auth-bugfix/improve-documentation
auth-bugfix/handle-401-status-codes
git add <files>gt create branch-name -m "commit message"gt submit --no-interactiveBefore creating branches, check if the current branch is tracked:
gt branch info
If you see "ERROR: Cannot perform this operation on untracked branch":
Option A (Recommended): Track temporarily, then re-parent
Track current branch: gt track -p main
Create your stack normally with gt create
After creating ALL branches, re-parent your first new branch onto main:
gt checkout <first-branch-of-your-stack> gt track -p main gt restack
Option B: Stash changes and start from main
git stashgit checkout main && git pullgit checkout -b temp-working && git stash popgt track -p main and gt create# Move up one branch (toward top of stack)
gt up
# Move down one branch (toward trunk)
gt down
# Jump to top of stack
gt top
# Jump to bottom of stack (first branch above trunk)
gt bottom
# View the full stack structure
gt ls
git add <files>
gt modify -m "updated commit message"
Use gt move to reorder branches in the stack. This is simpler than trying to use gt create --insert.
If you created a stack on top of a feature branch but want it based on main:
# Go to first branch of your stack
gt checkout <first-branch>
# Change its parent to main
gt track --parent main
# Rebase the entire stack
gt restack
gt rename new-branch-name
If changes are already committed but you want to re-stack them differently:
# Reset the last commit, keeping changes unstaged
git reset HEAD^
# Reset multiple commits (e.g., last 2 commits)
git reset HEAD~2
# View the diff to understand what you're working with
git diff HEAD
Before running gt submit, verify the first PR is parented on main:
gt ls
If the first branch has a parent other than main:
gt checkout <first-branch>
gt track -p main
gt restack
After creating each PR, run appropriate linting, building, and testing:
gt modifygt submit --no-interactive
After submitting, use gh pr edit to set proper titles and descriptions.
IMPORTANT: Never use Bash heredocs for PR descriptions - shell escaping breaks markdown tables, code blocks, etc. Instead:
Write tool to create /tmp/pr-body.md with the full markdown contentgh pr edit with --body-file:gh pr edit <PR_NUMBER> --title "stack-name: description" --body-file /tmp/pr-body.md
PR descriptions must include:
Example (for a PR in a 3-PR stack adding a warning feature):
## Stack Context
This stack adds a warning on the merge button when users are bypassing GitHub rulesets.
## Why?
Users who can bypass rulesets (via org admin or team membership) currently see no indication
they're circumventing branch protection. This PR threads the bypass data from the server to
enable the frontend warning (PR 2) to display it.
| Problem | Solution |
|---|---|
| "Cannot perform this operation on untracked branch" | Run gt track -p main first |
| Stack parented on wrong branch | Use gt track -p main then gt restack |
| Need to reorder PRs | Use gt move |
| Conflicts during restack | Resolve conflicts, then git rebase --continue |
| Want to split a PR | Reset commits (git reset HEAD^), re-stage selectively, create new branches |
In deeply nested stacks with many sibling branches, gt restack can be problematic:
git rebase Instead of gt restackUse direct git rebase when:
gt restack is hitting conflicts in unrelated branches# 1. Checkout the branch you want to rebase
git checkout my-feature-branch
# 2. Rebase onto the target (e.g., updated parent branch)
git rebase target-branch
# 3. If you hit conflicts:
# - Resolve the conflict in the file
# - Stage it: git add <file>
# - Continue: git rebase --continue
# 4. If a commit is obsolete and should be skipped:
git rebase --skip
# 5. After rebase, use gt modify to sync graphite's tracking
gt modify --no-edit
If a rebase was interrupted (e.g., Claude session ran out of context):
Check status:
git status # Look for "interactive rebase in progress" and "Unmerged paths"
Read the "unmerged" files - they may already be resolved (no conflict markers)
If already resolved, just stage and continue:
git add <resolved-files> git rebase --continue
If still has conflict markers , resolve them first, then stage and continue
# Delete a branch (non-interactive, even if not merged)
gt delete branch-to-delete -f -q
# Also delete all children (upstack)
gt delete branch-to-delete -f -q --upstack
# Also delete all ancestors (downstack)
gt delete branch-to-delete -f -q --downstack
Flags:
-f / --force: Delete even if not merged or closed-q / --quiet: Implies --no-interactive, minimizes outputAfter deleting intermediate branches , children are automatically restacked onto the parent. If you need to manually update tracking:
gt checkout child-branch
gt track --parent new-parent-branch
Weekly Installs
71
Repository
GitHub Stars
1
First Seen
Feb 19, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex71
cursor71
gemini-cli70
github-copilot70
kimi-cli70
amp70
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
125,600 周安装
Chroma 开源向量数据库:构建 RAG 应用,实现本地语义搜索与 AI 记忆
113 周安装
Stripe API升级指南:版本控制、SDK更新与破坏性变更处理
106 周安装
SharpSpring 营销自动化与 CRM 集成指南 - 使用 Membrane 快速连接
106 周安装
Agent Browser Relay 扩展:连接Chrome标签页提取DOM数据,实现浏览器自动化与数据分析
106 周安装
雪球大V动态汇总与投资建议工具:抓取大V观点、自选股行情,生成投资分析报告
107 周安装
Auth0 Fastify API 集成指南:使用 JWT 令牌保护 Node.js 后端服务
110 周安装
| Need to delete a branch (non-interactive) | gt delete <branch> -f -q |
gt restack hitting unrelated conflicts | Use targeted git rebase <target> instead (see below) |
| Rebase interrupted mid-conflict | Check if files are resolved but unstaged, then git add + git rebase --continue |