pilegit (pgit)
Git stacking with style — manage, squash, reorder, and submit stacked PRs from an interactive TUI.
Develop on a single branch, organize commits into reviewable chunks, submit each as a stacked PR. Full undo restores actual git state. Works with GitHub, GitLab, Gitea, Phabricator, and custom commands.
Install
Or build from source:
This installs the pgit binary.
Quick Start
Keybindings
| Key | Action |
|---|---|
j/↓ k/↑ |
Move cursor |
g / G |
Top / bottom |
Enter / Space |
Expand/collapse commit details |
d |
Full diff view |
V or Shift+↑↓ |
Start visual selection |
Ctrl+↑↓ or Ctrl+k/j |
Reorder commit (real git rebase -i) |
e |
Edit/amend commit |
i |
Insert new commit (after cursor or at top) |
x |
Remove commit from history |
r |
Rebase onto base branch + sync PRs |
p |
Submit or update PR for commit |
P |
Pull remote changes into local commits |
s |
Sync all submitted PRs |
R |
Refresh stack display (re-reads commits from git) |
u / Ctrl+r |
Undo / redo (restores git state) |
h |
View undo/redo history |
? |
Full help screen |
q |
Quit |
Select mode: V to start → j/k extend → s squash → Esc cancel
Diff view: j/k scroll · Ctrl+↑↓ half-page · q back
Setup
First run prompts for platform and base branch. Saved to .pilegit.toml:
[]
= "github" # github | gitlab | gitea | phabricator | custom
[]
= "origin/main"
| Platform | CLI | Install |
|---|---|---|
| GitHub | gh |
cli.github.com |
| GitLab | glab |
gitlab.com/gitlab-org/cli |
| Gitea | tea |
gitea.com/gitea/tea |
| Phabricator | arc |
arc install-certificate |
| Custom | any | Shell command with {hash}, {subject} placeholders |
Stacked PRs
Each commit → one PR. pilegit manages base branches so each PR shows only its diff:
Stack: PRs:
┌ feat: dashboard PR#15 base=pgit/.../feat-auth
│ feat: auth middleware PR#14 base=main (parent merged)
└ feat: migrations ← merged, branch cleaned up
Branch naming: pgit/<username>/<subject> — multi-user safe.
Press s to sync: force-push all branches, update bases, prompt to clean up stale branches.
Remote Pull
Press P to pull remote PR changes into your local stack. This enables collaboration — if someone else updates a PR in your stack, pgit detects the change and merges it into your local commits.
You submit PRs → colleague updates PR #2 → you press s
⚠ Remote has newer changes. Press P to pull first.
You press P → remote changes merged into local commits
✓ Pulled remote changes for 1 PRs.
You review, make more changes, then press s to sync.
Sync state is tracked in .git/pgit-sync-state.json (branch hashes for GitHub/GitLab/Gitea, diff PHIDs for Phabricator). Any push that doesn't match the saved state is flagged before overwriting.
Under the Hood
| Action | Git Operation |
|---|---|
| Reorder | git rebase -i with sed |
| Remove | git rebase -i → drop |
| Squash | git rebase -i → pick + squash |
| Edit | git rebase -i → edit + commit --amend |
| Undo | git reset --hard <saved-HEAD> |
| Submit | git branch -f + git push -f + CLI |
| Rebase | git fetch origin + git rebase origin/main |
Forge Trait
Adding a new platform = implementing one trait:
Comparison
| pilegit | git-branchless | graphite | ghstack | |
|---|---|---|---|---|
| Interactive TUI | ✓ | ✓ | – | – |
| Single-branch | ✓ | ✓ | – | ✓ |
| Stacked PRs | ✓ | partial | ✓ | ✓ |
| Multi-platform | 5 | git only | GitHub | GitHub |
| Undo/redo | ✓ | ✓ | – | – |
| No daemon | ✓ | – | – | ✓ |
Architecture
src/
├── main.rs # CLI — TUI, status, init
├── core/
│ ├── config.rs # .pilegit.toml + setup wizard
│ ├── stack.rs # Stack data model
│ └── history.rs # Undo/redo with HEAD hash tracking
├── git/
│ └── ops.rs # Git operations (rebase, squash, swap, etc.)
├── forge/
│ ├── mod.rs # Forge trait + factory
│ ├── github.rs # GitHub (gh)
│ ├── gitlab.rs # GitLab (glab)
│ ├── gitea.rs # Gitea (tea)
│ ├── phabricator.rs # Phabricator (arc)
│ └── custom.rs # Custom command
└── tui/
├── mod.rs # Terminal + suspend/resume handlers
├── app.rs # State machine (modes, cursor, forge)
├── input.rs # Keybinding dispatch
└── ui.rs # Ratatui rendering
License
MIT