Stack diff support for GitHub
Actively maintained. Last release 3 months ago, commits in 6 of the last 26 weeks. A safe choice.
pip install ghstackghstack
Conveniently submit stacks of diffs to GitHub as separate pull requests.
uv tool install ghstack
ghstack is tested with several different Python versions. It requires at least Python 3.9.1.
How to setup
Go to github.com Settings→Developer Settings→Personal Access Tokens and
generate a token with public_repo access only.
Create a ~/.ghstackrc as shown below:
λ cat ~/.ghstackrc
[ghstack]
github_url = github.com
github_oauth = [your_own_token]
github_username = [your_username]
remote_name = upstream [if remote is called upstream and not origin]
automsg = claude [optional; also supports codex]
You can toggle generated change descriptions with:
ghstack config automsg claude
ghstack config automsg codex
ghstack config automsg codex --model gpt-5.4
ghstack config --unset automsg
If automsg is set to claude or codex, ghstack writes
PR context (the local commit message and current PR description) to a temporary
file and invokes the agent with a prompt to summarize the specific update. The
patch update itself is included directly in the prompt. For existing PRs the
patch update is an interdiff against the previously submitted PR patch, not the
whole PR patch. Explicit ghstack -m MESSAGE still overrides this.
How to use
Make sure you have write permission to the repo you're opening PR with.
Prepare a series of commits on top of main, then run ghstack. This
tool will push and create pull requests for each commit on the stack.
How do I stack another PR on top of an existing one? Assuming
you've checked out the latest commit from the existing PR, just
git commit a new commit on top, and then run ghstack.
How do I modify a PR? Just edit the commit in question, and then
run ghstack again. If the commit is at the top of your stack,
you can edit it with git commit --amend; otherwise, you'll have
to use git rebase -i to edit the commit directly.
How do I rebase? The obvious way: git rebase origin/main.
Don't do a git merge; ghstack will throw a hissy fit if you
do that. (There's also a more fundamental reason why this
won't work: since each commit is a separate PR, you have to
resolve conflicts in PR, not just for the entire stack.)