Skip to content

Commit 224783f

Browse files
docs: README note on rebasing stacked PRs after the base merges (#58)
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 30cc722 commit 224783f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,30 @@ uv run pytest # 124 tests, ~2s
175175
uv run ruff check . # lint
176176
```
177177

178+
### Stacked pull requests
179+
180+
If PR B was opened on top of PR A's branch and A has since merged to
181+
main, B will show conflicts against main even though your own commits
182+
are clean. The conflicts are A's commits, now reachable from main via
183+
the merge, replaying against themselves.
184+
185+
Fix it by replaying only your commits onto main with
186+
`git rebase --onto main <old-base-sha> <branch>`. `<old-base-sha>` is
187+
the tip of A's branch at the moment you forked B — find it with
188+
`git merge-base <branch> <A-branch>` while A's branch still exists
189+
locally, or read it from the PR's "compare" base on github.com before
190+
the branch is deleted.
191+
192+
```bash
193+
# B = feature/b, was stacked on feature/a (now merged + deleted)
194+
git fetch origin
195+
old_base=$(git merge-base feature/b origin/main~1) # or paste the SHA
196+
git rebase --onto origin/main "$old_base" feature/b
197+
```
198+
199+
Then force-push with lease — never plain `--force`:
200+
`git push --force-with-lease`.
201+
178202
## Architecture
179203

180204
```

0 commit comments

Comments
 (0)