An interactive CLI tool for managing Git worktrees.
gw.mp4
- List worktrees with detailed status information (branch, changes, ahead/behind)
- Fuzzy search through worktrees and branches
- Create new worktrees from branches, tags, or HEAD
- Automatically copy gitignored files (.env) to new worktrees
- Delete single or multiple worktrees
- Switch worktrees with automatic directory change
- Rename worktrees and optionally their branches
- Cleanup old worktrees by age
- Execute hooks on worktree lifecycle events
- Edit and manage hooks through the interface
brew install wasabeef/gw-tap/gw
# Clone and install
git clone https://github.com/wasabeef/git-workers.git
cd git-workers
cargo install --path .
Add this to your shell config(.bashrc or .zshrc) to enable automatic directory switching when switching worktrees.
# For bash (~/.bashrc) or zsh (~/.zshrc)
source $(brew --prefix)/share/gw/shell/gw.sh
For manual installation, use the path where git-workers is installed:
source /path/to/git-workers/shell/gw.sh
Run gw
in any Git repository:
gw
Git Workers provides an interactive menu-driven interface. Simply run gw
and navigate through the options:
- List worktrees (
•
) - Display all worktrees with branch, changes, and sync status - Search worktrees (
?
) - Fuzzy search through worktree names and branches - Create worktree (
+
) - Create a new worktree with three options:- Create from current HEAD - Creates a new worktree with a new branch from the current HEAD
- Select branch - Choose from local/remote branches with fuzzy search:
- Shows local branches (💻) and remote branches (⛅️) with usage status
- Automatically handles branch conflicts (offers to create new branch if already in use)
- Fuzzy search enabled when >5 branches
- Select tag - Choose from tags to create a worktree at a specific version:
- Shows all tags (🏷️) with messages for annotated tags
- Creates a new branch from the selected tag
- Fuzzy search enabled when >5 tags
- Automatically copies configured files (.env, etc.) to new worktrees
- Delete worktree (
-
) - Delete a single worktree with safety checks - Batch delete (
=
) - Select and delete multiple worktrees at once (optionally deletes orphaned branches) - Cleanup old worktrees (
~
) - Remove worktrees older than specified days - Switch worktree (
→
) - Switch to another worktree (automatically changes directory) - Rename worktree (
*
) - Rename worktree directory and optionally its branch - Edit hooks (
λ
) - Configure lifecycle hooks in.git-workers.toml
- Exit (
x
) - Exit the application
Git Workers uses .git-workers.toml
for configuration. The loading strategy differs between bare and non-bare repositories:
For bare repositories (e.g., repo.git
), configuration is loaded from:
- Current directory
- Default branch directory in current directory (e.g.,
./main/.git-workers.toml
) - Detected worktree pattern (automatically finds where existing worktrees are organized)
- Common subdirectories (
branch/
,worktrees/
)
For regular repositories, configuration is loaded from:
- Current directory
- Main repository directory (where
.git
is a directory) - Parent directories'
main/
ormaster/
subdirectories
[repository]
# Optional: Specify repository URL to ensure hooks only run in the intended repository
# url = "https://github.com/owner/repo.git"
[repository]
# Repository URL for identification (optional)
# This ensures hooks only run in the intended repository
url = "https://github.com/wasabeef/git-workers.git"
[hooks]
# Run after creating a new worktree
post-create = [
"echo '🤖 Created worktree: {{worktree_name}}'",
"echo '🤖 Path: {{worktree_path}}'"
]
# Run before removing a worktree
pre-remove = [
"echo '🤖 Removing worktree: {{worktree_name}}'"
]
# Run after switching to a worktree
post-switch = [
"echo '🤖 Switched to: {{worktree_name}}'"
]
[files]
# Optional: Specify a custom source directory
# If not specified, automatically finds the main worktree
# source = "/path/to/custom/source"
# source = "./templates" # Relative to repository root
# Files to copy when creating new worktrees
# These are typically gitignored files needed for development
copy = [
".env",
".env.local"
]
{{worktree_name}}
: The name of the worktree{{worktree_path}}
: The absolute path to the worktree
When creating your first worktree, Git Workers offers two patterns:
-
Same level as repository: Creates worktrees as siblings to your main repository
parent/ ├── my-repo/ ├── feature-1/ └── feature-2/
-
In subdirectory (recommended): Organizes worktrees in a dedicated directory
parent/ └── my-repo/ └── worktrees/ ├── feature-1/ └── feature-2/
You can also create worktrees with custom paths:
../feature
: Creates at the same level as the repositoryworktrees/feature
: Creates in a subdirectorybranch/feature
: Creates in a custom subdirectory structure
- ESC: Cancel current operation and return to menu
- Ctrl+C: Exit the application
- Ctrl+U: Clear input line
- Ctrl+W: Delete word before cursor
- Arrow Keys: Navigate menus
- Enter: Confirm selection
See CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.