Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
54d836d
git primitives for modify cmd
skarim Apr 30, 2026
630e36f
extract reusable TUI parts
skarim Apr 30, 2026
6eabcc8
modify cmd
skarim Apr 30, 2026
fb557c6
recreate stack after modify
skarim Apr 30, 2026
b998ac8
add checks to prevent other modifications while modify is applying
skarim Apr 30, 2026
684ecea
modify continue for resuming after resolving conflicts
skarim Apr 30, 2026
a236373
fix bug with duplicate stack entries after modifying
skarim May 1, 2026
a08e189
reuse conflict resolution help msg from rebase
skarim May 1, 2026
0a320ce
additional confirmation before overwriting stack on remote
skarim May 1, 2026
7778715
fix recreate order of operations
skarim May 3, 2026
00609df
move base commit instead of cherry picking for fold up
skarim May 3, 2026
f8ec509
check to ensure we aren't left with zero branches
skarim May 3, 2026
8e11fdb
unify and dedupe across view and modify tui
skarim May 3, 2026
7636f50
more detailed help instructions
skarim May 3, 2026
d9a6dde
only recommend submit if stack exists on remote
skarim May 3, 2026
9025606
tests for modify tui, apply modifications, submit modifications
skarim May 3, 2026
f20a0a3
refactor submit for regular and pending modifications
skarim May 3, 2026
be0aa25
rename recover to abort
skarim May 3, 2026
b685096
docs for modify cmd
skarim May 3, 2026
7b6e7e4
tui styling updates
skarim May 4, 2026
9c974f8
updated tui screenshot
skarim May 4, 2026
ce918bf
addressing review comments
skarim May 4, 2026
9aab998
Fix 4 bugs from code review
skarim May 4, 2026
7f33691
Fix 7 nit issues from code review
skarim May 4, 2026
c1a8cbe
Make cherry-pick conflicts recoverable via --continue
skarim May 4, 2026
f4f3fc9
Apply suggestions from code review
skarim May 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,68 @@ gh stack rebase --continue
gh stack rebase --abort
```

### `gh stack modify`

Interactively restructure the current stack.

```
gh stack modify [flags]
```

Opens a terminal UI for restructuring a stack. You can rename, drop, reorder, and fold branches into adjacent ones. All the changes are staged during the preview and applied at once on save.

If the stack of PRs has been created on GitHub, run `gh stack submit` afterwards to push the changes and recreate the stack.

| Flag | Description |
|------|-------------|
| `--continue` | Continue after resolving conflicts |
| `--abort` | Abort the modify session and restore the stack to its pre-modify state |

**Operations:**

- **Drop** (`x`): Remove a branch and its commits from the stack. Local branch and associated PR are preserved.
- **Fold down** (`d`): Absorb a branch's commits into the branch below (toward trunk). Folded branch removed from stack.
- **Fold up** (`u`): Absorb a branch's commits into the branch above (away from trunk). Folded branch removed from stack.
- **Reorder** (`Shift+↑`/`Shift+↓`): Move a branch up (away from trunk) or down (toward trunk) in the stack.
- **Rename** (`r`): Rename a branch locally and in the stack metadata.
- **Undo** (`z`): Undo the last staged action.

**Keybindings:**

| Key | Action |
|-----|--------|
| `↑`/`↓` | Navigate branch list |
| `f` | View files changed |
| `c` | View commits |
| `x` | Drop branch |
| `r` | Rename branch |
| `u/d` | Fold branch up/down |
| `Shift+↑`/`Shift+↓` | Move branch up/down |
| `z` | Undo last action |
| `Ctrl+S` | Apply all changes |
| `q`/`Esc` | Cancel and exit |
| `?` | Help |

**Preconditions:**
- Must have an active stack checked out locally
- Working tree must be clean
- No rebase in progress
- No PR in the stack is queued for merge
- Commit history must be linear

**Examples:**

```sh
# Open the modify TUI
gh stack modify

# Continue after resolving a conflict
gh stack modify --continue

# Abort and restore to the previous state
gh stack modify --abort
```

### `gh stack sync`

Fetch, rebase, push, and sync PR state in a single command.
Expand Down
7 changes: 7 additions & 0 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/github/gh-stack/internal/branch"
"github.com/github/gh-stack/internal/config"
"github.com/github/gh-stack/internal/git"
"github.com/github/gh-stack/internal/modify"
"github.com/github/gh-stack/internal/stack"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -54,6 +55,12 @@ func runAdd(cfg *config.Config, opts *addOptions, args []string) error {
return ErrNotInStack
}
gitDir := result.GitDir

if err := modify.CheckStateGuard(gitDir); err != nil {
cfg.Errorf("%s", err)
return ErrModifyRecovery
}

sf := result.StackFile
s := result.Stack
currentBranch := result.CurrentBranch
Expand Down
Loading