Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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-create hooks (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-create hooks if the worktree was auto-created
  • Runs post-switch hooks after switching

Configuration

Disable auto-creation:

[worktree]
auto-create = false

gwt remove

Remove a worktree.

gwt remove <branch> [--keep-branch] [--force]

Options

OptionDescription
--keep-branchDon’t delete the git branch
--force, -fForce removal even if the worktree has uncommitted changes

Behavior

  • You cannot remove the worktree you’re currently in
  • Runs pre-remove hooks (closes Zellij tab, stops gateway apps)
  • Removes the worktree directory
  • Deletes the branch unless --keep-branch is 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 *.