monkey-git
v1.0.13
Published
Git worktree workflow tools — jump between branches, clean up merged worktrees, and stay productive.
Downloads
1,383
Maintainers
Readme
🐒 monkey
Git worktree workflow tools. Jump between branches in isolated worktrees, clean up when done.
Install
npm install -g monkey-gitHow It Works
~/Sites/
├── my-project/ ← main worktree (dev branch)
├── my-project-feat/login/ ← monkey jump feat/login
├── my-project-fix/bug-123/ ← monkey jump fix/bug-123Each worktree is a full working copy sharing the same .git objects — no cloning, instant creation.
Commands
| Command | Description |
|---------|-------------|
| monkey jump <branch> | Create a worktree, run setup, and open in editor |
| monkey jump --term <branch> | Same, but open a terminal instead of the editor |
| monkey jump --no-open <branch> | Create and setup the worktree without opening anything |
| monkey jump --from-base <branch> | Fork from the main worktree instead of the current branch |
| monkey drop [branch] | Remove a worktree and delete its branch |
| monkey list | List all active worktrees with clean/dirty status |
| monkey swap <branch> | Open an existing worktree in your editor |
| monkey prune | Clean up worktrees for branches already merged into base |
| monkey config | Show current configuration |
Safety guards
monkey drop prompts for confirmation (y/N) when:
- The worktree has uncommitted changes
- The branch is not merged into the base branch
Configuration
git config monkey.baseBranch dev # Base branch for prune (default: auto-detects dev/main/master)
git config monkey.editor cursor # Preferred editor (default: auto-detects from environment)Project Setup Hooks
When monkey jump creates a new worktree, it looks for a setup script in the current worktree (where you ran the command) and runs it inside the new worktree directory.
Resolution order:
.local.monkey.sh— personal/local setup (add to.gitignore).monkey.sh— shared team setup (commit to repo)- Auto-install — if neither exists, detects your package manager (
pnpm/yarn/npm/bun) from the lockfile and runs install automatically
Scripts run inside the new worktree directory with these environment variables:
$ROOT— the worktree you ranmonkey jumpfrom$MAIN_ROOT— the main worktree (first worktree, typically your base branch)
Example: .monkey.sh (shared, committed)
#!/usr/bin/env bash
# Shared setup — runs for every team member on `monkey jump`
# Install dependencies
pnpm install
# Copy environment file from main worktree
cp "$MAIN_ROOT/.env" .env
# Run codegen
pnpm api:codegenExample: .local.monkey.sh (personal, gitignored)
#!/usr/bin/env bash
# Personal overrides — takes priority over .monkey.sh
pnpm install
# Use my local dev database
cp "$MAIN_ROOT/.env" .env
sed -i '' 's/DATABASE_URL=.*/DATABASE_URL=postgres:\/\/localhost:5432\/mydb/' .env
# Symlink large assets from main worktree instead of copying
ln -sf "$MAIN_ROOT/public/assets" public/assetsShell Integration
Completions
# Zsh — add to ~/.zshrc
fpath=("$(npm root -g)/monkey-git/lib/completions" $fpath)
autoload -Uz compinit && compinit
# Bash — add to ~/.bashrc
source "$(npm root -g)/monkey-git/lib/completions/monkey.bash"Shell function mode
Source the init script to get monkey-jump/monkey-drop style functions alongside the monkey CLI:
# Add to ~/.zshrc or ~/.bashrc
source "$(npm root -g)/monkey-git/lib/shell-init.sh"Platform Support
Works on macOS, Linux, and Windows (Git Bash / WSL). Editor auto-detection checks git config monkey.editor → $VISUAL → Cursor → VS Code → system default (open / xdg-open / start).
License
MIT
