README
ΒΆ
Worktree Util
A simple TUI (Terminal User Interface) for managing Git worktrees, built with Go and Bubble Tea.
Features
- π List all git worktrees in your repository
- β Add new worktrees with custom branches (auto-organized in
.worktrees/folder) - ποΈ Remove worktrees safely
- π¨ Beautiful terminal interface with keyboard navigation
- β οΈ Smart error handling with helpful messages
- π Simple workflow - just enter a branch name, path is auto-generated
Installation
Homebrew (macOS/Linux)
brew install abtris/tap/worktree-util
Download Binary
Download the latest release for your platform from the releases page.
Build from Source
git clone https://github.com/abtris/worktree-util.git
cd worktree-util
go build -o worktree-util
Usage
TUI Mode
Run the tool from within a git repository to start the interactive TUI:
./worktree-util
CLI Commands
Manage configuration from the command line:
# Show current configuration
worktree-util config
# Initialize config file with defaults
worktree-util config init
# Set configuration values
worktree-util config set worktree_dir my-worktrees
# Get configuration values
worktree-util config get worktree_dir
# Add files to copy to new worktrees
worktree-util config add-copy-file .env
worktree-util config add-copy-file .env.local
# Remove files from copy list
worktree-util config remove-copy-file .env
# Show help
worktree-util --help
# Show version
worktree-util --version
Keyboard Shortcuts
List View
a- Add a new worktreed- Delete selected worktreer- Refresh the listβ/β- Navigate through worktreesq- Quit
Add Worktree View
Enter- Create the worktreeEsc- Cancel and return to list
Delete Confirmation
y- Confirm deletionnorEsc- Cancel deletion
Requirements
- Go 1.21 or higher
- Git installed and available in PATH
- Must be run from within a git repository
How It Works
The tool uses git worktree commands under the hood:
git worktree list --porcelain- to list worktreesgit worktree add- to create new worktreesgit worktree remove- to delete worktrees
Auto-Generated Paths
When you create a new worktree, you only need to provide the branch name. The tool automatically:
- Creates a
.worktrees/directory in your repository root (if it doesn't exist) - Sanitizes the branch name (e.g.,
feature/new-featureβfeature-new-feature) - Creates the worktree at
.worktrees/<sanitized-branch-name>
This keeps all your worktrees organized in one place!
Configuration
Worktree Util supports optional configuration via ~/.config/worktree-util/config.yml.
Creating a Configuration File
-
Create the config directory:
mkdir -p ~/.config/worktree-util -
Create
~/.config/worktree-util/config.yml:# Directory where worktrees will be created (relative to repo root) worktree_dir: .worktrees # Files to copy from repo root to new worktrees copy_files: - .env - .env.local
Configuration Options
-
worktree_dir: Directory where worktrees will be created (relative to repository root)- Default:
.worktrees - Examples:
.worktrees- Creates worktrees in.worktrees/folderworktrees- Creates worktrees inworktrees/folder../my-worktrees- Creates worktrees outside the repository
- Default:
-
copy_files: List of files to copy from repository root to new worktrees- Default:
[](no files copied) - Useful for files in
.gitignorethat are needed for development (e.g.,.envfiles) - Files that don't exist will be silently skipped
- Supports nested paths (e.g.,
config/local.yml) - Examples:
copy_files: - .env - .env.local - config/local.yml
- Default:
See config.example.yml for a complete example.
Note: Configuration is completely optional. If no config file exists, the tool uses sensible defaults.
Example Workflow
- Run
./worktree-utilin your git repository - Press
ato add a new worktree - Enter the branch name (e.g.,
feature/new-feature) - Watch the path auto-generate (e.g.,
.worktrees/feature-new-feature) - Press
Enterto create - The new worktree will appear in the list
Your worktrees will be organized like this:
my-repo/
βββ .git/
βββ .worktrees/
β βββ feature-new-feature/
β βββ bugfix-123/
β βββ experiment-api/
βββ src/
βββ README.md
License
MIT
worktree-util
Documentation
ΒΆ
There is no documentation for this package.