| Crates.io | gwtx |
| lib.rs | gwtx |
| version | 0.5.0 |
| created_at | 2026-01-05 19:34:26.219048+00 |
| updated_at | 2026-01-14 14:48:54.009639+00 |
| description | git worktree extra - CLI tool to enhance git worktree with automated setup tasks |
| homepage | https://github.com/h-michael/gwtx |
| repository | https://github.com/h-michael/gwtx |
| max_upload_size | |
| id | 2024448 |
| size | 309,666 |
CLI tool that enhances git worktree with automated setup and utilities.
Note: This tool is under active development. Commands and configuration format may change in future versions.
Every time you create a git worktree, you end up doing the same manual setup:
.env.local.env.example to .envgwtx reads .gwtx.yaml from your repository and runs these tasks automatically when creating a worktree.
cargo install gwtx
See INSTALL.md for other installation methods (mise, Nix, GitHub Releases).
# Create a worktree with setup
gwtx add ../feature-branch
# Create a new branch and worktree
gwtx add -b new-feature ../new-feature
# Interactive mode - select branch and path
gwtx add --interactive
# Preview without executing
gwtx add --dry-run ../test
# List all worktrees with detailed information (branch, commit hash, status)
gwtx list
gwtx ls # Short alias
# Show header row with column names
gwtx list --header
# List only worktree paths (useful for scripting)
gwtx list --path-only
gwtx ls -p
Status Symbols:
* = Uncommitted changes (modified, deleted, or untracked files)Note: Use git status in the worktree directory for detailed status information.
# Remove a worktree with safety checks
gwtx remove ../feature-branch
# Interactive mode - select worktrees to remove
gwtx remove --interactive
# Preview what would be removed
gwtx remove --dry-run ../feature-branch
# Force removal (skip safety checks and confirmation)
gwtx remove --force ../feature-branch
Safety Checks:
By default, gwtx remove warns about:
Use --force to bypass all checks and confirmation prompts.
# Show config format help
gwtx config
# Validate configuration
gwtx config validate
Hooks allow you to run custom commands before/after worktree operations:
# Review and trust hooks in .gwtx.yaml
gwtx trust
# Show hooks without trusting
gwtx trust --show
# Revoke trust
gwtx untrust
# List all trusted repositories
gwtx untrust --list
Security: For security, hooks require explicit trust via gwtx trust before execution. See Hooks Configuration below.
Create .gwtx.yaml in your repository root. See examples/ for various use cases.
JSON Schema: The configuration format is validated against a JSON Schema located at schema/gwtx.schema.json. This schema can be used with editors that support YAML schema validation for autocomplete and validation.
Editor Integration: To enable schema validation in VS Code or other editors using yaml-language-server, add this comment at the top of your .gwtx.yaml:
# yaml-language-server: $schema=https://raw.githubusercontent.com/h-michael/gwtx/main/schema/gwtx.schema.json
options:
on_conflict: backup
options:
on_conflict: backup # abort, skip, overwrite, backup
mkdir:
- path: build
description: Build output directory
link:
- source: .env.local
description: Local environment
copy:
- source: .env.example
target: .env
description: Environment template
Operations:
mkdir - Create directorieslink - Create symbolic linkscopy - Copy files or directoriesExamples: examples/basic.yaml
Configure default worktree path with template variables:
worktree:
path: ../worktrees/{branch}
Template variables:
{{branch}} or {{ branch }} - Branch name (e.g., feature/foo){{repository}} or {{ repository }} - Repository name (e.g., myrepo)Examples: examples/worktree-path.yaml
Use glob patterns in link operations to match multiple files:
link:
- source: fixtures/*
skip_tracked: true
description: Link untracked test fixtures
Supported patterns:
* - matches any characters? - matches a single character[...] - matches character ranges** - matches directories recursivelyOptions:
skip_tracked: true - Skip git-tracked files (useful for linking only untracked files like local configs or test data)Examples: examples/glob-patterns.yaml
Execute custom commands before/after worktree operations. Requires explicit trust via gwtx trust.
hooks:
post_add:
- command: npm install
description: Install dependencies
- command: mise install
description: Install mise tools
Hook types:
pre_add - Before worktree creationpost_add - After worktree setuppre_remove - Before worktree removalpost_remove - After worktree removalTemplate variables:
{{worktree_path}} - Full path to worktree{{worktree_name}} - Worktree directory name{{branch}} - Branch name{{repo_root}} - Repository rootSecurity:
gwtx trust before executionExamples: examples/hooks-basic.yaml, examples/nodejs-project.yaml
| Operation | Description |
|---|---|
mkdir |
Create directories |
link |
Create symbolic links |
copy |
Copy files or directories |
hooks.* |
Run custom commands (requires trust) |
When a target file already exists, gwtx can:
abort - Stop immediately (default in non-interactive mode)skip - Skip the file and continueoverwrite - Replace the existing filebackup - Rename existing file to .bak and proceedSet globally in options, per-operation, or via --on-conflict flag.
| Option | Description |
|---|---|
--interactive, -i |
Select branch and path interactively |
--dry-run |
Preview actions without executing |
--quiet, -q |
Suppress output |
--no-setup |
Skip setup (run git worktree add only) |
Passes through git worktree options:
gwtx add [OPTIONS] [PATH] [COMMITISH]
gwtx Options:
-i, --interactive Interactive mode
--on-conflict <MODE> abort, skip, overwrite, backup
--dry-run Preview without executing
--no-setup Skip .gwtx.yaml setup
git worktree Options:
-b <name> Create new branch
-B <name> Create or reset branch
-f, --force Force creation
-d, --detach Detach HEAD
--no-checkout Do not checkout after creation
--lock Lock worktree after creation
--track / --no-track Branch tracking
--guess-remote Guess remote for tracking
--no-guess-remote Do not guess remote
Shared:
-q, --quiet Suppress output
Remove worktrees with safety checks:
gwtx remove [OPTIONS] [PATHS]...
gwtx Options:
-i, --interactive Select worktrees interactively
--dry-run Preview without executing
git worktree Options:
-f, --force Force removal (skip all checks and prompts)
Shared:
-q, --quiet Suppress output
Interactive Mode Keybindings:
↑/↓ or Ctrl+n/p - NavigateSpace - Toggle selection→ (Right arrow) - Select all← (Left arrow) - Clear allEnter - ConfirmEsc or Ctrl+c - CancelGenerate completion scripts for your shell:
# Bash
gwtx completions bash > ~/.local/share/bash-completion/completions/gwtx
# Zsh (add ~/.zfunc to your fpath)
gwtx completions zsh > ~/.zfunc/_gwtx
# Fish
gwtx completions fish > ~/.config/fish/completions/gwtx.fish
# PowerShell (add to your profile)
gwtx completions powershell >> $PROFILE
# PowerShell (or save to a file and dot-source it)
gwtx completions powershell > _gwtx.ps1
# Then add to $PROFILE: . /path/to/_gwtx.ps1
Supported shells: bash, elvish, fish, powershell, zsh
To find your PowerShell profile path, run echo $PROFILE. If the profile file doesn't exist, create it with New-Item -Path $PROFILE -ItemType File -Force.
Generate and install the man page:
# Install to system
sudo gwtx man > /usr/local/share/man/man1/gwtx.1
# View without installing
gwtx man | man -l -
Hooks are currently supported on Unix-like systems (Linux, macOS) only.
Windows support is not yet available. For Windows users:
--no-setup flag to skip hooksOn Windows, creating symbolic links requires one of the following:
Without these permissions, [[link]] operations will fail with a permission error.
For more information, see:
MIT OR Apache-2.0