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: README.md
+89-11
Original file line number
Diff line number
Diff line change
@@ -37,10 +37,80 @@ pipx install .
37
37
38
38
## Workflow
39
39
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.
42
41
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:
44
114
45
115
-`submit` (or `export`) - create a new stack of PRs from the given set of
46
116
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:
52
122
-`abandon` - remove all stack metadata from the given set of commits. Apart
53
123
from removing the metadata from the affected commits, this command deletes
54
124
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.
58
127
59
128
A usual workflow is the following:
60
129
@@ -70,7 +139,8 @@ You can also use `view` at any point to examine the current state, and
70
139
`abandon` to drop the stack.
71
140
72
141
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,
74
144
but you are not supposed to work with those branches or edit that metadata
75
145
manually. I.e. instead of pushing to these branches you should use `submit`,
76
146
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
88
158
The first step before creating a stack of PRs is to double-check the changes
89
159
we’re going to post.
90
160
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
92
162
a PR forevery commitin that range.
93
163
94
164
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
172
242
feedback), we simply amend the desired changes to the appropriate git commits
173
243
and run `submit` again. If needed, we can rearrange commits or add new ones.
174
244
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
+
175
249
When we are ready to merge our changes, we use `land` command.
0 commit comments