A CLI tool for managing Git worktrees using a bare repository structure.
-
Install:
pipx install git+https://github.com/jlothian/worktree-tool.git
Or from a local clone:
pip install . -
Add shell wrapper & autocompletions (add this to
~/.zshrcor~/.bashrc):eval "$(gwt-cli init-shell)"
(For local development, you can instead source
source aliases.sh)
Clones the repository as a bare repository into <directory>/.bare, sets up the main worktree (checking out the remote HEAD branch or the custom branch name if --main is specified), and configures upstream tracking.
Fetches remote updates, updates main, and branches off it. Slashes in the branch name are converted to dashes in the directory name. Automatically cds the shell into the new directory.
Scans worktrees merged into main and deletes them. Automatically detects and cleans up squash-merged branches by comparing tree hashes against recent commits on the main branch. If a merged worktree has dirty/untracked files, surfaces the files and prompts before deleting.
Displays a status table of all active worktrees, branches, merge status, and clean/dirty status. Run wt list -i or wt list --interactive to launch an interactive selection picker (powered by fzf) that previews and automatically changes directory (cd) to the selected worktree. (Requires fzf installed).
Navigates to an existing worktree. If a worktree name (directory name or branch name) is provided, it outputs the path to that worktree. If no name is provided, it launches an interactive fzf picker to select a worktree and outputs its path. The shell wrapper automatically cds to the selected worktree. (Interactive mode requires fzf installed).
Deletes a specific worktree and its associated branch. If no name is provided, launches an interactive fzf selection picker (excluding the main and active worktrees). Includes safety prompts if the worktree has uncommitted changes or if its branch is not merged into main. The -f or --force flag bypasses all prompts.
Fixes broken worktree pointer paths if the project directory is relocated.
Prints the current version of the tool.
Run the automated integration tests:
python3 -m unittest discover -s tests