Skip to content

Commit 44fd8e7

Browse files
committed
Update docs.
1 parent 0158123 commit 44fd8e7

File tree

1 file changed

+89
-11
lines changed

1 file changed

+89
-11
lines changed

README.md

+89-11
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,80 @@ pipx install .
3737

3838
## Workflow
3939

40-
`stack-pr` is a tool allowing you to work with stacked PRs: submit,
41-
view, and land them.
40+
`stack-pr` allows you to work with stacked PRs: submit, view, and land them.
4241

43-
The `stack-pr` tool has four commands:
42+
### Basic Workflow
43+
44+
The most common workflow is simple:
45+
46+
1. Create a feature branch from `main`:
47+
```bash
48+
git checkout main
49+
git pull
50+
git checkout -b my-feature
51+
```
52+
53+
2. Make your changes and create multiple commits (one commit per PR you want to create)
54+
```bash
55+
# Make some changes
56+
git commit -m "First change"
57+
# Make more changes
58+
git commit -m "Second change"
59+
# And so on...
60+
```
61+
62+
3. Review what will be in your stack:
63+
```bash
64+
stack-pr view # Always safe to run, helps catch issues early
65+
```
66+
67+
4. Create/update the stack of PRs:
68+
```bash
69+
stack-pr submit
70+
```
71+
**Note**: `export` is an alias for `submit`.
72+
73+
5. To update any PR in the stack:
74+
- Amend the corresponding commit
75+
- Run `stack-pr view` to verify your changes
76+
- Run `stack-pr submit` again
77+
78+
6. To rebase your stack on the latest main:
79+
```bash
80+
git checkout my-feature
81+
git pull origin main # Get the latest main
82+
git rebase main # Rebase your commits on top of main
83+
stack-pr submit # Resubmit to update all PRs
84+
```
85+
86+
7. When your PRs are ready to merge, you have two options:
87+
88+
Option A: Using `stack-pr land`:
89+
```bash
90+
stack-pr land
91+
```
92+
This will:
93+
- Merge the bottom-most PR in your stack
94+
- Automatically rebase your remaining PRs
95+
- You can run `stack-pr land` again to merge the next PR once CI passes
96+
97+
Option B: Using GitHub web interface:
98+
1. Merge the bottom-most PR through GitHub UI
99+
2. After the merge, on your local machine:
100+
```bash
101+
git checkout my-feature
102+
git pull origin main # Get the merged changes
103+
stack-pr submit # Resubmit the stack to rebase remaining PRs
104+
```
105+
3. Repeat for each PR in the stack
106+
107+
That's it! No need to use `-H` or `-B` flags for this basic workflow - the tool will automatically look at all commits between `main` and your current branch.
108+
109+
**Pro-tip**: Run `stack-pr view` frequently - it's a safe command that helps you understand the current state of your stack and catch any potential issues early.
110+
111+
### Commands
112+
113+
`stack-pr` has four main commands:
44114

45115
- `submit` (or `export`) - create a new stack of PRs from the given set of
46116
commits. One can think of this as “push my local changes to the corresponding
@@ -52,9 +122,8 @@ The `stack-pr` tool has four commands:
52122
- `abandon` - remove all stack metadata from the given set of commits. Apart
53123
from removing the metadata from the affected commits, this command deletes
54124
the corresponding local and remote branches and closes the PRs.
55-
- `land` - merge PRs from the stack corresponding to the given set of commits.
56-
This command attempts to merge PRs from the stack one by one, and if
57-
succeeded deletes the corresponding branches from local and remote repos.
125+
- `land` - merge the bottom-most PR in the current stack and rebase the rest of
126+
the stack on the latest main.
58127

59128
A usual workflow is the following:
60129

@@ -70,7 +139,8 @@ You can also use `view` at any point to examine the current state, and
70139
`abandon` to drop the stack.
71140
72141
Under the hood the tool creates and maintains branches named
73-
`$USERNAME/stack/$BRANCH_NUM` and embeds stack metadata into commit messages,
142+
`$USERNAME/stack/$BRANCH_NUM` (the name pattern can be customized via
143+
`--branch-name-template` option) and embeds stack metadata into commit messages,
74144
but you are not supposed to work with those branches or edit that metadata
75145
manually. I.e. instead of pushing to these branches you should use `submit`,
76146
instead of deleting them you should use `abandon` and instead of merging them
@@ -88,7 +158,7 @@ and `-T` respectively and accept the standard git notation: e.g. one can use
88158
The first step before creating a stack of PRs is to double-check the changes
89159
we’re going to post.
90160
91-
By default the tool will look at commits in `main..HEAD` range and will create
161+
By default `stack-pr` will look at commits in `main..HEAD` range and will create
92162
a PR for every commit in that range.
93163
94164
For instance, if we have
@@ -172,6 +242,10 @@ If we need to make changes to any of the PRs (e.g. to address the review
172242
feedback), we simply amend the desired changes to the appropriate git commits
173243
and run `submit` again. If needed, we can rearrange commits or add new ones.
174244
245+
`submit` simply syncs the local changes with the corresponding PRs. This is why
246+
we use the same `stack-pr submit` command when we create a new stack, rebase our
247+
changes on the latest main, or update any PR in the stack.
248+
175249
When we are ready to merge our changes, we use `land` command.
176250
177251
```python
@@ -238,6 +312,10 @@ stack-pr view -B HEAD~5 -H HEAD~2
238312
stack-pr land -B HEAD~5 -H HEAD~2
239313
```
240314
315+
Note that generally one doesn't need to specify the base and head branches
316+
explicitly - `stack-pr` will figure out the correct range based on the current
317+
branch and the remote `main` by default.
318+
241319
## Command Line Options Reference
242320
243321
### Common Arguments
@@ -259,7 +337,7 @@ These arguments can be used with any subcommand:
259337
260338
#### submit (alias: export)
261339
262-
Submit a stack of PRs
340+
Submit a stack of PRs.
263341
264342
Options:
265343
@@ -271,13 +349,13 @@ Options:
271349
272350
#### land
273351
274-
Land the current stack
352+
Land the bottom-most PR in the current stack.
275353
276354
Takes no additional arguments beyond common ones.
277355
278356
#### abandon
279357
280-
Abandon the current stack
358+
Abandon the current stack.
281359
282360
Takes no additional arguments beyond common ones.
283361

0 commit comments

Comments
 (0)