wtman is a CLI tool for managing Git worktrees more conveniently.
It automates worktree path naming using templates and executes routine tasks like npm install or copying .env files through hooks. With separate team and user configurations that merge automatically, it's easy to adopt in any project.
- Template-based path generation - Automatically determine worktree paths from branch names
- Hook automation - Execute commands and file operations when creating or removing worktrees
- Three-layer configuration merge - Automatically merge team, user, and worktree-specific settings
- Metadata management - Attach descriptions and tags to worktrees
npm install -g wtman# Create a worktree
wtman add feature/awesome-feature
# Create with description and tags
wtman add feature/auth --desc "Implement authentication" --tag feature,wip
# List worktrees
wtman list
# Remove a worktree (interactive selection)
wtman removeCreate a new worktree.
wtman add <branch> [--desc <description>] [--tag <tags>]| Option | Description |
|---|---|
--desc |
Set a description for the worktree |
--tag |
Set tags (comma-separated) |
Workflow:
- Load configuration and generate path from
worktree.template - Execute
pre-worktree-addhooks - Create worktree with
git worktree add - Execute
post-worktree-addhooks - Save metadata
Remove a worktree. Running without arguments opens interactive selection.
wtman remove [-b <branch>] [-w <path>] [--force] [--delete-branch|--keep-branch]| Option | Description |
|---|---|
-b |
Specify by branch name |
-w |
Specify by path |
--force |
Skip confirmation and force removal |
--delete-branch |
Also delete the branch |
--keep-branch |
Keep the branch |
Safety features:
- Warns if there are uncommitted changes
- Warns if there are commits not pushed to remote
Display a list of worktrees.
wtman list [-f <format>]| Option | Value | Description |
|---|---|---|
-f |
table |
Table format (default) |
json |
JSON format | |
tsv |
Tab-separated format |
Configuration is written in YAML format. There are three levels of configuration files that merge automatically.
| File | Purpose | Git-tracked |
|---|---|---|
.wtman/config.yaml |
Team shared settings | Yes |
.wtman/config.user.yaml |
User-specific settings | No |
.wtman/config.user.worktree.yaml |
Worktree-specific settings | No |
Merge order: Team → User → Worktree (later settings take precedence)
Note: It's recommended to add
config.user.*.yamlto.gitignore
worktree:
template: "../${{ original.basename }}-${{ worktree.branch }}" # Path template
separator: hyphen # hyphen | underscore | slash
deleteBranch: ask # ask | always | never
pre-worktree-add: [] # Hooks before worktree creation
post-worktree-add: [] # Hooks after worktree creation
pre-worktree-remove: [] # Hooks before worktree removal
post-worktree-remove: [] # Hooks after worktree removal# .wtman/config.yaml
worktree:
template: "../${{ original.basename }}-${{ worktree.branch }}"
separator: hyphen
post-worktree-add:
- name: Install dependencies
run: npm install
- name: Copy environment file
copy: .env.example
- name: Link node_modules
link: node_modulesYou can define processes that automatically execute when creating or removing worktrees.
| Phase | Timing | Default Working Directory |
|---|---|---|
pre-worktree-add |
Before creation | Main tree |
post-worktree-add |
After creation | Worktree |
pre-worktree-remove |
Before removal | Worktree |
post-worktree-remove |
After removal | Main tree |
post-worktree-add:
- name: Install dependencies
run: npm installCopy files from the main tree to the worktree.
post-worktree-add:
- name: Copy config files
copy:
- .env.example
- config/local/Create symbolic links in the worktree pointing to the main tree.
post-worktree-add:
- name: Link shared directories
link:
- node_modules
- .cachepost-worktree-add:
- name: Create directories
mkdir:
- logs
- tmppre-worktree-remove:
- name: Clean up
remove:
- .env.local
- logs/Use the working-directory option to change the working directory.
post-worktree-add:
- name: Install frontend dependencies
working-directory: frontend
run: npm installYou can embed variables using the ${{ variable.name }} format.
| Variable | Description | Example |
|---|---|---|
${{ original.path }} |
Absolute path of main tree | /home/user/project |
${{ original.basename }} |
Directory name of main tree | project |
${{ worktree.path }} |
Absolute path of worktree | /home/user/project-feature |
${{ worktree.basename }} |
Directory name of worktree | project-feature |
${{ worktree.branch }} |
Branch name | feature-auth |
Note:
worktree.pathandworktree.basenameare only available inpost-worktree-addandpre-worktree-remove
Use worktree.separator to convert / in branch names.
| separator | Input | Output |
|---|---|---|
hyphen |
feature/auth |
feature-auth |
underscore |
feature/auth |
feature_auth |
slash |
feature/auth |
feature/auth |
You can attach descriptions and tags to worktrees. They are stored in .wtman/worktrees.yaml.
# Set when adding
wtman add feature/auth --desc "Authentication feature" --tag feature,high-priority
# View in list
wtman list