https://github.com/ogirginc/workbush
Manage git worktrees with automatic file copying and setup commands
https://github.com/ogirginc/workbush
git worktree
Last synced: 2 months ago
JSON representation
Manage git worktrees with automatic file copying and setup commands
- Host: GitHub
- URL: https://github.com/ogirginc/workbush
- Owner: ogirginc
- License: mit
- Created: 2025-10-30T17:32:18.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-10-30T17:32:32.000Z (4 months ago)
- Last Synced: 2025-12-06T17:50:25.407Z (2 months ago)
- Topics: git, worktree
- Language: Ruby
- Homepage: https://rubygems.org/gems/workbush
- Size: 12.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# 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 `.env` files
- Re-running `bundle install` or `npm install`
- Copying `node_modules` or `vendor/bundle` to 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:
```bash
gem install workbush
```
Or add to your Gemfile:
```ruby
gem 'workbush'
```
## Quick Start
1. **Initialize configuration** in your project:
```bash
workbush init
```
2. **Edit `.workbush.yml`** to match your needs:
```yaml
copy_files:
- .env
- .env.local
- mise.local.toml
copy_directories:
- node_modules
- vendor/bundle
post_create_commands:
- mise trust
- bundle install
- rails db:migrate
```
3. **Create a worktree** with automatic setup:
```bash
workbush add ../feature-123 feature-branch
```
That's it! Your new worktree is ready with all files copied and commands executed.
## Usage
### Create a worktree
```bash
# 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-branch
```
### List worktrees
```bash
workbush list
```
### Remove a worktree
```bash
# With confirmation prompt
workbush remove ../feature-123
# Force removal without confirmation
workbush remove --force ../feature-123
```
### Initialize configuration
```bash
# Create .workbush.yml in current directory
workbush init
# Overwrite existing config
workbush init --force
```
### Show version
```bash
workbush version
```
## Configuration
Create a `.workbush.yml` file in your project root:
```yaml
# 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:migrate
```
### ERB Templates
Use ERB for dynamic configuration:
```yaml
copy_files:
- <%= ENV.fetch("CONFIG_FILE", ".env") %>
post_create_commands:
- <%= ENV.fetch("SETUP_COMMAND", "bundle install") %>
```
## Use Cases
### Rails Development
```yaml
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:migrate
```
### Node.js Projects
```yaml
copy_files:
- .env
- .env.local
copy_directories:
- node_modules
post_create_commands:
- npm install
- npm run build
```
### Ruby Gems
```yaml
copy_directories:
- vendor/bundle
post_create_commands:
- bundle install
```
## Global Options
All commands support these options:
- `--verbose` or `-v`: Enable detailed output
- `--config PATH` or `-c PATH`: Use custom config file
## Tips
1. **Commit your `.workbush.yml`**: Share configuration with your team
2. **Copy `node_modules`**: Much faster than re-running `npm install`
3. **Use glob patterns**: Copy all `.env.*` files at once
4. **Skip commands when needed**: Use `--no-run-commands` for quick testing
5. **Check the list**: Use `workbush list` to 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](https://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](https://opensource.org/licenses/MIT).