A simple CLI tool for managing git worktrees. Create feature branches in isolated directories, switch between them easily, and clean up when done.
brew tap joch/ygg
brew install ygggo install github.com/joch/ygg/cmd/ygg@latestgo build -o ygg ./cmd/yggygg new my-featureThis will:
- Fetch latest from origin
- Create a new worktree with branch
my-featurebased on the default branch - Enter a subshell in the new worktree directory
Worktrees are created at .worktrees/<feature-name> inside the repository root.
ygg listShows all worktrees. Current worktree is marked with *, modified ones show [modified].
ygg switch my-featureEnters a subshell in the specified worktree.
ygg remove my-feature # remove by name
ygg remove # remove current worktree
ygg rm my-feature # aliasUse --force to remove even with uncommitted changes or unmerged branches.
ygg clean # prompts for confirmation
ygg clean --dry-run # show what would be removed
ygg clean --force # no confirmationRemoves worktrees whose branches have been merged to main.
| Command | Description |
|---|---|
ygg new <name> |
Create a new worktree and enter it |
ygg list |
List all worktrees |
ygg switch <name> |
Switch to a worktree |
ygg remove [name] |
Remove a worktree |
ygg clean |
Remove merged worktrees |
# Bash
source <(ygg completion bash)
# Zsh
source <(ygg completion zsh)
# Fish
ygg completion fish | sourceAdd to your shell rc file for persistent completion.
When inside a ygg shell, $YGG_WORKTREE is set to the current worktree name. Add to your prompt:
# Bash/Zsh
PS1='${YGG_WORKTREE:+[$YGG_WORKTREE] }'$PS1When running inside a zellij session, ygg automatically creates named tabs instead of spawning subshells. No configuration needed — it detects zellij via the ZELLIJ environment variable.
ygg new my-featurecreates a tab named<repo>/my-featurewith the worktree as the working directoryygg switch my-featurefocuses the existing tab, or creates one if it doesn't exist
If zellij commands fail for any reason, ygg falls back to the normal subshell behavior.
ygg includes a skill file for AI coding agents that teaches them how to use ygg for worktree management.
ygg skill installygg skill uninstallygg spawns subshells in worktree directories. When you're done, exit to return to where you started.
Inside a ygg shell, ygg switch changes directory directly instead of nesting shells.
- Go 1.22+
- Git
MIT
