|
| 1 | +# wt-cli |
| 2 | + |
| 3 | +Git worktree management CLI with colored status and Claude integration. |
| 4 | + |
| 5 | +[](https://github.com/jorgensandhaug/wt-cli/actions/workflows/test.yml) |
| 6 | + |
| 7 | +## Install |
| 8 | + |
| 9 | +```bash |
| 10 | +curl -sSL https://raw.githubusercontent.com/jorgensandhaug/wt-cli/main/install.sh | bash |
| 11 | +``` |
| 12 | + |
| 13 | +### Requirements |
| 14 | + |
| 15 | +- `git` |
| 16 | +- `jq` (`brew install jq` on macOS, `apt install jq` on Ubuntu) |
| 17 | +- bash or zsh |
| 18 | + |
| 19 | +### Uninstall |
| 20 | + |
| 21 | +```bash |
| 22 | +curl -sSL https://raw.githubusercontent.com/jorgensandhaug/wt-cli/main/uninstall.sh | bash |
| 23 | +``` |
| 24 | + |
| 25 | +## Commands |
| 26 | + |
| 27 | +| Command | Description | |
| 28 | +|---------|-------------| |
| 29 | +| `wt new <branch>` | Create new worktree with new branch | |
| 30 | +| `wt new -b <branch>` | Create worktree from existing branch (auto-fetches) | |
| 31 | +| `wt new -p <pr>` | Create worktree from GitHub PR (requires gh CLI) | |
| 32 | +| `wt new -u <branch>` | Create worktree and run 'up' commands | |
| 33 | +| `wt ls` | List all worktrees with colored status | |
| 34 | +| `wt cd [name]` | cd to worktree (main if no name) | |
| 35 | +| `wt up` | Spin up dev environment (run 'up' commands) | |
| 36 | +| `wt down` | Spin down dev environment (run 'down' commands) | |
| 37 | +| `wt rm [name]` | Remove worktree (current if no name given) | |
| 38 | +| `wt rm -f [name]` | Force remove (ignores dirty/unpushed warnings) | |
| 39 | +| `wt purge` | Interactive cleanup of clean worktrees | |
| 40 | +| `wt prune` | Clean stale worktree references | |
| 41 | +| `wt config` | Show config file path | |
| 42 | +| `wt update` | Self-update to latest version | |
| 43 | +| `wt version` | Show version | |
| 44 | + |
| 45 | +## Directory Structure |
| 46 | + |
| 47 | +``` |
| 48 | +parent/ |
| 49 | + myrepo/ |
| 50 | + .worktrees/ |
| 51 | + myrepo/ |
| 52 | + feature-x/ |
| 53 | + bugfix/login/ |
| 54 | +``` |
| 55 | + |
| 56 | +## Status Indicators |
| 57 | + |
| 58 | +`wt ls` shows status: |
| 59 | + |
| 60 | +- `[ok]` - Clean and pushed |
| 61 | +- `[unpushed]` - Has unpushed commits |
| 62 | +- `[dirty]` - Has uncommitted changes |
| 63 | + |
| 64 | +## Configuration |
| 65 | + |
| 66 | +### User Config |
| 67 | + |
| 68 | +`~/.config/wt/config.json`: |
| 69 | + |
| 70 | +```json |
| 71 | +{ |
| 72 | + "command": "claude --dangerously-skip-permissions" |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +The `command` runs after creating a new worktree. |
| 77 | + |
| 78 | +### Project Config |
| 79 | + |
| 80 | +`.cursor/worktrees.json`: |
| 81 | + |
| 82 | +```json |
| 83 | +{ |
| 84 | + "setup-worktree": ["npm install", "cp .env.example .env"], |
| 85 | + "up": ["docker-compose up -d", "npm run dev &"], |
| 86 | + "down": ["docker-compose down"], |
| 87 | + "cleanup-worktree": ["rm -rf node_modules"] |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +- `setup-worktree`: Runs after creating worktree (always) |
| 92 | +- `up`: Runs with `wt up` or `wt new -u` (spin up services) |
| 93 | +- `down`: Runs with `wt down` (spin down services) |
| 94 | +- `cleanup-worktree`: Runs before removing worktree (always) |
| 95 | + |
| 96 | +See [docs/CONFIGURATION.md](docs/CONFIGURATION.md) for details. |
| 97 | + |
| 98 | +## Example Workflow |
| 99 | + |
| 100 | +```bash |
| 101 | +# Start a new feature |
| 102 | +wt new auth-refactor |
| 103 | + |
| 104 | +# Start a feature and spin up dev environment |
| 105 | +wt new -u auth-refactor |
| 106 | + |
| 107 | +# Work on an existing remote branch |
| 108 | +wt new -b origin/feature-api |
| 109 | + |
| 110 | +# Review a PR |
| 111 | +wt new -p 123 |
| 112 | + |
| 113 | +# See all worktrees |
| 114 | +wt ls |
| 115 | + |
| 116 | +# Switch worktrees |
| 117 | +wt cd feature-api |
| 118 | + |
| 119 | +# Go back to main |
| 120 | +wt cd |
| 121 | + |
| 122 | +# Spin up dev environment |
| 123 | +wt up |
| 124 | + |
| 125 | +# Spin down dev environment |
| 126 | +wt down |
| 127 | + |
| 128 | +# Done with feature - remove current worktree |
| 129 | +wt rm |
| 130 | + |
| 131 | +# Clean up all finished worktrees |
| 132 | +wt purge |
| 133 | + |
| 134 | +# Update wt-cli |
| 135 | +wt update |
| 136 | +``` |
| 137 | + |
| 138 | +See [docs/EXAMPLES.md](docs/EXAMPLES.md) for more examples. |
| 139 | + |
| 140 | +## Contributing |
| 141 | + |
| 142 | +See [CONTRIBUTING.md](CONTRIBUTING.md). |
| 143 | + |
| 144 | +## License |
| 145 | + |
| 146 | +[MIT](LICENSE) |
0 commit comments