A CLI tool for managing git worktrees during patch review workflows.
Build from source:
CGO_ENABLED=0 go buildOr use go install to fetch and build the binary, installing it into $HOME/go/bin/patch-review:
CGO_ENABLED=0 GOPROXY=direct go install github.com/jwdevantier/patch-review@latest- Create a configuration file at
~/.config/patch-review/patch-review.config.toml:
[settings]
branch_prefix = "review"
default_source = "qemu"
[sources.qemu]
path = "~/repos/qemu"
branch = "nvme.next"
remote = "staging"
[sources.linux]
path = "/path/to/linux"
branch = "main"
remote = "origin"- Create a review directory:
patch-review reset ~/reviews/my-patchThis creates a new git worktree with a fresh branch based on the latest upstream code.
- Apply a patch:
patch-review apply ~/reviews/my-patch.patch ~/reviews/my-patch- Clean up when done:
patch-review rm ~/reviews/my-patchCreates or refreshes a git worktree directory.
patch-review reset [--source <name>] <review-dir>- Fetches latest updates from the configured remote
- Creates a new branch from the upstream branch
- Creates a new worktree at the specified path
- If the worktree already exists, it removes and recreates it
Use --source to specify a source (defaults to default_source in config).
Removes a worktree and cleans up git state.
patch-review rm <review-dir>- Validates the path is a known worktree
- Removes the worktree directory
- Deletes the associated git branch
- Updates state tracking
Applies a patch file to a worktree.
patch-review apply <review-dir> <patch-file>- Validates the worktree path is known
- Applies the patch using
git am
Config files are stored in ~/.config/patch-review/ by default. Override with --dir.
[settings]
branch_prefix = "review" # Prefix for created branches
default_source = "qemu" # Default source when --source not specified
[sources.<name>]
path = "~/repos/qemu" # Path to repository
branch = "nvme.next" # Branch to use as base
remote = "staging" # Git remote to fetch frompatch-review.state.json tracks active worktrees. Do not edit manually.
--dir <path>: Override config directory location
.
├── main.go # Entry point, CLI setup
├── cmds/
│ ├── reset.go # reset command
│ ├── rm.go # rm command
│ └── apply.go # apply command
├── internal/
│ ├── config.go # Configuration loading (TOML)
│ ├── state.go # State persistence (JSON)
│ └── git.go # Git operations
├── go.mod / go.sum # Dependencies
└── DESIGN.md # Design document
- spf13/cobra - CLI framework
- BurntSushi/toml - TOML parsing
go build .go test ./...