Workbush 🌳
Manage git worktrees with automatic file copying and setup commands. Workbush simplifies the process of creating git worktrees by automatically copying dependencies, configuration files, and running setup commands based on a simple YAML configuration.
Why Workbush?
Git worktrees are powerful for working on multiple branches simultaneously, but setting them up can be tedious:
- Manually copying
.envfiles - Re-running
bundle installornpm install - Copying
node_modulesorvendor/bundleto avoid reinstalling - Running database migrations
- Copying other configuration files
Workbush automates all of this with a single command.
Features
- Automatic file copying: Copy dependencies, configs, and build artifacts
- Post-creation commands: Run setup commands automatically
- Glob pattern support: Copy files matching patterns
- YAML configuration: Simple, version-controlled setup
- ERB templates: Dynamic configuration with environment variables
- Thor-based CLI: Beautiful, colorized output
Installation
Install the gem:
gem install workbushOr add to your Gemfile:
gem 'workbush'Quick Start
- Initialize configuration in your project:
workbush init-
Edit
.workbush.ymlto match your needs:
copy_files:
- .env
- .env.local
- mise.local.toml
copy_directories:
- node_modules
- vendor/bundle
post_create_commands:
- mise trust
- bundle install
- rails db:migrate- Create a worktree with automatic setup:
workbush add ../feature-123 feature-branchThat's it! Your new worktree is ready with all files copied and commands executed.
Usage
Create a worktree
# Create worktree for existing branch
workbush add ../feature-123 feature-branch
# Create worktree with new branch
workbush add ../bug-fix new-branch-name
# Create without copying files
workbush add --no-copy ../quick-test main
# Create without running commands
workbush add --no-run-commands ../feature-456 feature-branch
# Create with verbose output
workbush add --verbose ../feature-789 feature-branch
# Force creation (overwrite existing path)
workbush add --force ../existing-path feature-branchList worktrees
workbush listRemove a worktree
# With confirmation prompt
workbush remove ../feature-123
# Force removal without confirmation
workbush remove --force ../feature-123Initialize configuration
# Create .workbush.yml in current directory
workbush init
# Overwrite existing config
workbush init --forceShow version
workbush versionConfiguration
Create a .workbush.yml file in your project root:
# Files to copy (exact paths)
copy_files:
- .env
- .env.local
- .env.development
- config/database.yml
- config/credentials.yml.enc
# Glob patterns for multiple files
copy_patterns:
- ".env.*"
- "*.lock"
- "config/*.local"
# Directories to copy
copy_directories:
- node_modules
- vendor/bundle
- .bundle
- tmp/cache
# Commands to run after creation
post_create_commands:
- bundle install
- yarn install
- rails db:migrateERB Templates
Use ERB for dynamic configuration:
copy_files:
- <%= ENV.fetch("CONFIG_FILE", ".env") %>
post_create_commands:
- <%= ENV.fetch("SETUP_COMMAND", "bundle install") %>Use Cases
Rails Development
copy_files:
- .env
- mise.local.toml
- config/database.yml
- config/master.key
copy_directories:
- vendor/bundle
- node_modules
post_create_commands:
- mise trust
- bundle install
- yarn install
- rails db:migrateNode.js Projects
copy_files:
- .env
- .env.local
copy_directories:
- node_modules
post_create_commands:
- npm install
- npm run buildRuby Gems
copy_directories:
- vendor/bundle
post_create_commands:
- bundle installGlobal Options
All commands support these options:
-
--verboseor-v: Enable detailed output -
--config PATHor-c PATH: Use custom config file
Tips
-
Commit your
.workbush.yml: Share configuration with your team -
Copy
node_modules: Much faster than re-runningnpm install -
Use glob patterns: Copy all
.env.*files at once -
Skip commands when needed: Use
--no-run-commandsfor quick testing -
Check the list: Use
workbush listto see all your worktrees
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/workbush.
License
The gem is available as open source under the terms of the MIT License.