Skip to content

Commit 910b69c

Browse files
committed
force push with lease by default
1 parent c2a1106 commit 910b69c

4 files changed

Lines changed: 8 additions & 12 deletions

File tree

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,17 @@ Push all branches in the current stack and create or update pull requests.
197197
gh stack push [flags]
198198
```
199199

200-
Pushes every branch to the remote, then for each branch either creates a new PR (with the correct base branch) or updates the base of an existing PR if it has changed.
200+
Pushes every branch to the remote, then for each branch either creates a new PR (with the correct base branch) or updates the base of an existing PR if it has changed. Uses `--force-with-lease` by default to safely update rebased branches.
201201

202202
| Flag | Description |
203203
|------|-------------|
204-
| `-f, --force` | Force-push branches |
205204
| `--draft` | Create new PRs as drafts |
206205
| `--dry-run` | Show what would be pushed without actually pushing |
207206

208207
**Examples:**
209208

210209
```sh
211210
gh stack push
212-
gh stack push --force
213211
gh stack push --draft
214212
gh stack push --dry-run
215213
```
@@ -350,8 +348,8 @@ gh stack bottom
350348
# 6. Rebase the rest of the stack on top of your fix
351349
gh stack rebase
352350

353-
# 7. Force-push the updated stack
354-
gh stack push --force
351+
# 7. Push the updated stack
352+
gh stack push
355353

356354
# 8. When the first PR is merged, sync the stack
357355
gh stack sync

cmd/push.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
)
1111

1212
type pushOptions struct {
13-
force bool
1413
draft bool
1514
dryRun bool
1615
}
@@ -26,7 +25,6 @@ func PushCmd(cfg *config.Config) *cobra.Command {
2625
},
2726
}
2827

29-
cmd.Flags().BoolVarP(&opts.force, "force", "f", false, "Force-push branches")
3028
cmd.Flags().BoolVar(&opts.draft, "draft", false, "Create PRs as drafts")
3129
cmd.Flags().BoolVar(&opts.dryRun, "dry-run", false, "Show what would be pushed without pushing")
3230

@@ -83,7 +81,7 @@ func runPush(cfg *config.Config, opts *pushOptions) error {
8381
}
8482

8583
cfg.Printf("Pushing %s...", b.Branch)
86-
if err := git.Push("origin", []string{b.Branch}, opts.force, false); err != nil {
84+
if err := git.Push("origin", []string{b.Branch}, true, false); err != nil {
8785
cfg.Errorf("failed to push %s: %s", b.Branch, err)
8886
return nil
8987
}

cmd/rebase.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func runRebase(cfg *config.Config, opts *rebaseOptions) error {
320320

321321
cfg.Printf("%s rebased locally with %s", rangeDesc, s.Trunk.Branch)
322322
cfg.Printf("To push up your changes and open/update the stack of PRs, run %s",
323-
cfg.ColorCyan("gh stack push -f"))
323+
cfg.ColorCyan("gh stack push"))
324324

325325
return nil
326326
}
@@ -505,7 +505,7 @@ func continueRebase(cfg *config.Config, gitDir string) error {
505505

506506
cfg.Printf("All branches in stack rebased locally with %s", s.Trunk.Branch)
507507
cfg.Printf("To push up your changes and open/update the stack of PRs, run %s",
508-
cfg.ColorCyan("gh stack push -f"))
508+
cfg.ColorCyan("gh stack push"))
509509

510510
return nil
511511
}

cmd/sync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,10 @@ func runSync(cfg *config.Config, _ *syncOptions) error {
249249
if !force {
250250
cfg.Warningf("Push failed — branches may need force push after rebase")
251251
cfg.Printf(" Run %s to push with --force-with-lease.",
252-
cfg.ColorCyan("gh stack push -f"))
252+
cfg.ColorCyan("gh stack push"))
253253
} else {
254254
cfg.Warningf("Push failed: %v", err)
255-
cfg.Printf(" Run %s to retry.", cfg.ColorCyan("gh stack push -f"))
255+
cfg.Printf(" Run %s to retry.", cfg.ColorCyan("gh stack push"))
256256
}
257257
} else {
258258
cfg.Successf("Pushed %d branches", len(branches))

0 commit comments

Comments
 (0)