create / switch / remove / list
gwt create
Create a new worktree without switching to it.
gwt create <branch>
Behavior
- Creates a worktree at
<worktree.path>/<sanitized-branch>/ - Runs
post-createhooks (e.g., installs dependencies, adds a Zellij tab) - If a hook fails, the worktree creation is rolled back
gwt switch
Switch to a worktree. If it doesn’t exist and worktree.auto-create is enabled (default), creates it first.
gwt switch <branch>
Behavior
- Inside Zellij: switches to the worktree’s tab
- Outside Zellij: prints the worktree path (useful for
cd $(gwt switch feat/x)) - Runs
post-createhooks if the worktree was auto-created - Runs
post-switchhooks after switching
Configuration
Disable auto-creation:
[worktree]
auto-create = false
gwt remove
Remove a worktree.
gwt remove <branch> [--keep-branch] [--force]
Options
| Option | Description |
|---|---|
--keep-branch | Don’t delete the git branch |
--force, -f | Force removal even if the worktree has uncommitted changes |
Behavior
- You cannot remove the worktree you’re currently in
- Runs
pre-removehooks (closes Zellij tab, stops gateway apps) - Removes the worktree directory
- Deletes the branch unless
--keep-branchis passed - If the branch has unmerged commits, gwt prompts for confirmation before force-deleting
- In non-interactive mode (
GWT_AUTO_APPROVE=1), unmerged branches are kept with a warning
gwt list
List all worktrees.
gwt list
Output
* main /path/to/project
feat/my-feature /path/to/project/.worktrees/feat-my-feature
fix/bug-123 /path/to/project/.worktrees/fix-bug-123
The current worktree is marked with *.