You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/content/docs/faq.md
+35-1Lines changed: 35 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,7 +100,41 @@ You cannot merge a PR in the middle of the stack before the PRs below it are mer
100
100
101
101
### How does squash merge work?
102
102
103
-
Squash merges are fully supported. Each PR in the stack produces one clean, squashed commit when merged. The rebase engine automatically detects squash-merged PRs and replays commits from the remaining branches onto the squashed result.
103
+
Squash merges are fully supported. Each PR in the stack produces one clean, squashed commit when merged. Merging `n` PRs will create `n` squashed commits on the base.
104
+
105
+
When a PR is squash-merged, the original commits disappear from the history, which can cause artificial merge conflicts during rebasing. Both the CLI and the server handle this using `git rebase --onto`:
106
+
107
+
```
108
+
git rebase --onto <new_commit_sha_generated_by_squash> <original_commit_sha_from_tip_of_merged_branch> <branch_name>
109
+
```
110
+
111
+
**Example:** Consider a stack with three PRs:
112
+
113
+
```
114
+
PR1: main ← A, B (branch1)
115
+
PR2: main ← A, B, C, D (branch2)
116
+
PR3: main ← A, B, C, D, E, F (branch3)
117
+
```
118
+
119
+
When PR1 and PR2 are squash-merged, `main` now looks like:
120
+
121
+
```
122
+
S1 (squash of A+B), S2 (squash of C+D)
123
+
```
124
+
125
+
Then the following rebase is run:
126
+
127
+
```
128
+
git rebase --onto S2 D branch3
129
+
```
130
+
131
+
Which rewrites `branch3` to:
132
+
133
+
```
134
+
S1, S2, E, F
135
+
```
136
+
137
+
This moves the unique commits from the unmerged branch and replays them on top of the newly squashed commits on the base branch, avoiding any merge conflicts.
Copy file name to clipboardExpand all lines: docs/src/content/docs/introduction/overview.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,6 +77,7 @@ Rebasing is the trickiest part of working with Stacked PRs, and GitHub handles i
77
77
-**In the PR UI** — A rebase button lets you trigger a cascading rebase across all branches in the stack.
78
78
-**From the CLI** — `gh stack rebase` performs the same cascading rebase locally.
79
79
-**After partial merges** — When you merge a PR at the bottom of the stack, the remaining branches are automatically rebased so the next PR targets `main` and is ready for review and merge.
80
+
-**Safe squash-merge handling** — Squash merges are fully supported. The rebase engine safely replays your unique commits on top of the squashed base, avoiding artificial merge conflicts. See the [FAQ](/gh-stack/faq/#how-does-squash-merge-work) for a detailed description of how this works.
0 commit comments