Grove is a CLI tool that encapsulates the patterns that I use for working with Git worktrees locally on my machine. To learn more about this pattern, you can check out this blog post.
- Initialize repos with a bare clone optimized for worktrees
- Create, list, and remove worktrees
- Sync with origin and prune stale worktrees
- Self-update to the latest version or PR build
curl -fsSL https://safia.rocks/grove/install.sh | shThis will download the appropriate binary for your system and install it to ~/.grove/bin.
Note: Grove currently supports Linux and macOS only. Windows support is not available.
To install a specific version:
curl -fsSL https://safia.rocks/grove/install.sh | sh -s -- v1.0.0Create a new directory structure optimized for git worktree workflows:
grove init https://github.com/user/repo.gitThis command will:
- Create a directory named after the repository (e.g.,
repo/) - Clone the repository as a bare clone into
repo/repo.git/ - Configure the remote fetch to support all branches
- Provide instructions for creating worktrees
After initialization, you can create worktrees:
cd repo
grove add main
grove add feature/new-featureCreate a new worktree for a branch:
grove add feature/new-featureTrack a remote branch:
grove add feature/new-feature --track origin/feature/new-featureRemove a worktree:
grove remove feature/new-featureForce removal even with uncommitted changes:
grove remove feature/new-feature --forceSkip confirmation prompt:
grove remove feature/new-feature --yesOpen a new shell session in a worktree directory:
grove go feature-branchThis spawns a new shell in the worktree directory. Exit the shell (Ctrl+D or exit) to return to your previous directory.
You can also navigate by partial branch name for nested branches:
# If you have a worktree for feature/my-feature
grove go my-featureThe GROVE_WORKTREE environment variable is set to the branch name while in the worktree shell.
grove listShow detailed information:
grove list --detailsShow only dirty worktrees:
grove list --dirtyUpdate the bare clone with the latest changes from origin:
grove syncThis fetches the default branch (main or master) from origin and updates the local reference.
Sync a specific branch:
grove sync --branch developPreview what would be removed:
grove prune --dry-runRemove worktrees for branches merged to main:
grove pruneForce removal even if worktrees have uncommitted changes:
grove prune --forceUse a different base branch:
grove prune --base developRemove worktrees older than a specific duration (bypasses merge check):
Note: When using --older-than, the merge status check is bypassed, and all worktrees older than the specified duration will be removed. The --base flag cannot be used with --older-than.
You can use human-friendly formats (e.g., 30d, 2w, 6M, 1y) or ISO 8601 duration format (e.g., P30D, P2W, P6M, P1Y):
# Remove worktrees older than 30 days
grove prune --older-than 30d
# Remove worktrees older than 6 months
grove prune --older-than 6M
# Remove worktrees older than 1 year
grove prune --older-than 1y
# Preview what would be removed for worktrees older than 2 weeks
grove prune --older-than 2w --dry-run
# ISO 8601 format is also supported
grove prune --older-than P30DUpdate grove to the latest version:
grove self-updateUpdate to a specific version:
grove self-update v1.0.0
# or
grove self-update 1.0.0Update to a specific PR build (requires GitHub CLI):
grove self-update --pr 42Note: The self-update command uses the same installation script as the initial installation. If you installed grove using the quick install method, this command will update the binary in ~/.grove/bin. If you installed grove using a different method (e.g., manually downloading the binary), you may need to update it manually.
grove init <git-url>- Create a new worktree setupgrove add <name> [options]- Create a new worktreegrove go <name>- Navigate to a worktreegrove remove <name> [options]- Remove a worktreegrove list [options]- List all worktreesgrove sync [options]- Sync the bare clone with origingrove prune [options]- Remove worktrees for merged branchesgrove self-update [version] [options]- Update grove to a specific version or PRgrove version- Show version informationgrove help [command]- Show help
- Node.js 20.0 or later
- Bun (https://bun.sh)
- Git
# Clone the repository
git clone https://github.com/captainsafia/grove.git
cd grove
# Install dependencies
bun install
# Build the project
bun run build
# Build single-file executable
bun run build:compile# Build the project
bun run build
# Build single-file executable for current platform
bun run build:compile
# Cross-compile for specific platforms
bun run build:linux-x64
bun run build:darwin-arm64
# Type check the code
bun run typecheck
# Run tests
bun test
# Clean build artifacts
bun run clean