A CLI tool to create and manage git worktrees for Laravel projects with automatic environment setup for Laravel Herd.
- Create git worktrees with automatic Laravel environment setup
- Configure
.envfiles with correctAPP_URLandDB_DATABASE - Auto-install Composer and NPM dependencies
- Generate new
APP_KEYfor isolated worktrees (optional) - Copy databases between worktrees (MySQL and SQLite)
- Open worktrees directly in PHPStorm
- Works seamlessly with Laravel Herd's
.testdomain convention
- Python 3.7+
- Git
- Laravel Herd (for automatic
.testdomain routing) - Composer
- MySQL CLI tools (optional, for database copying)
sudo curl -o /usr/local/bin/wt https://raw.githubusercontent.com/histonedev/wt-tool/main/wt.py
sudo chmod +x /usr/local/bin/wtgit clone https://github.com/histonedev/wt-tool.git ~/.wt-tool
sudo ln -s ~/.wt-tool/wt.py /usr/local/bin/wtmkdir -p ~/.local/bin
curl -o ~/.local/bin/wt https://raw.githubusercontent.com/histonedev/wt-tool/main/wt.py
chmod +x ~/.local/bin/wt
# Add to PATH if needed: export PATH="$HOME/.local/bin:$PATH"Run commands from within your Laravel project directory.
# Create worktree from existing branch
wt add feature/payments
# Create worktree with a new branch
wt add -b feature/new-feature
# Create worktree and copy database
wt add --db feature/payments
# Create worktree with a fresh APP_KEY
wt add --key feature/payments
# Combine flags
wt add -b --db --key feature/payments
# Specify custom folder name
wt add feature/payments my-custom-folder# Remove worktree only
wt remove project-payments
# Remove worktree and drop database
wt remove --db project-paymentswt listwt open project-paymentswt --version- Worktree Creation: Creates a git worktree in the parent directory of your main project
- Environment Setup: Copies
.envfrom main project and updates:APP_URLtohttp://<folder-name>.testDB_DATABASEto match folder name
- Dependencies: Automatically runs
composer installandnpm install - APP_KEY (with
--keyflag): Generates a fresh application key - Database (with
--dbflag): Copies MySQL database or SQLite file from source
~/Sites/
├── my-laravel-app/ # Main project
├── my-laravel-app-feature/ # Worktree for feature branch
└── my-laravel-app-hotfix/ # Worktree for hotfix branch
Worktrees follow Laravel Herd's convention:
- Folder:
my-laravel-app-feature - URL:
http://my-laravel-app-feature.test
The tool auto-detects your database driver from .env:
- MySQL/MariaDB: Uses
mysqldumpto copy databases (requiresmysqlandmysqldumpCLI tools) - SQLite: Copies the
database/database.sqlitefile
MIT License - see LICENSE for details.