Treekanga is a powerful CLI tool for managing Git worktrees with ease. It simplifies the creation, management, and cleanup of worktrees, enhancing your Git workflow.
- Create new worktrees with smart branch handling
- List all worktrees in a repository
- Delete worktrees with stale branch filtering and interactive selector
- Clone repositories as bare worktrees
- Zoxide integration for quick navigation
- Simple YAML configuration
brew install garrettkrohn/treekanga/treekanga
Create a YAML configuration file at ~/.config/treekanga/treekanga.yml
:
# Example Configuration
repos:
# Repository name
exampleRepository:
# Default branch used when no base branch is specified
defaultBranch: development
#where should treekanga put the worktrees, assumes starting in the $HOME directory
worktreeTargetDir: /code
# Folders to register with zoxide for quick navigation
zoxideFolders:
- frontEnd
- frontEnd/* # adds all folders immediately within frontEnd
- backEnd
- backEnd/application/src/main/resources/db/migration
postScript: ~/dotfiles/scripts/test_script.sh
autoRunPostScript: false
treekanga:
defaultBranch: main
zoxideFolders:
- cmd
- git
Create a new worktree with a branch:
# Specify branch and base branch
treekanga add example_branch -b example_base_branch
# Use default base branch from config
treekanga add example_branch
# Pull the base branch before creating new branch
treekanga add example_branch -p
# Open in Cursor after creation
treekanga add example_branch -c
# Open in VS Code after creation
treekanga add example_branch -v
# Connect to a sesh session after creation
treekanga add example_branch -s session_name
# Specify custom directory for bare repo
treekanga add example_branch -d /path/to/bare/repo
Branch handling logic:
- If
example_branch
exists locally: Create a worktree with that branch - If
example_branch
exists remotely: Create a worktree with a new local version of that branch - With base branch specified:
- If base branch exists locally: Create a new branch off the local base branch
- If using the pull flag (
-p
): Create a new branch off the remote base branch - If base branch doesn't exist locally: Create new worktree with new branch off remote base branch
Display all worktrees in the current repository:
treekanga list
Interactive deletion of worktrees:
# Delete any worktrees interactively
treekanga delete
# Only show worktrees where branches don't exist on remote (stale worktrees)
treekanga delete --stale
# Also delete the local branches (use with caution)
treekanga delete --delete
Clone a repository as a bare worktree:
treekanga clone https://www.github.com/example/example
Control log verbosity:
treekanga --log debug [command]
Garrett Krohn