A Git worktree management tool for efficient parallel development with automatic directory navigation.
- π Quick worktree creation with smart branch handling
- π¦ Automatic remote branch fetching
- π Automatic directory navigation (cd) after operations
- π₯οΈ Optional tmux integration (auto-split panes when available)
- π Easy navigation between worktrees and main repository
- π List and switch between worktrees interactively
- ποΈ Clean worktree removal with automatic navigation
- π― Intuitive naming convention for worktree directories
npx git-work-space installThis will install the git work command globally on your system.
git work start <branch> # Create worktree and switch to it
git work list # List all worktrees with numbers
git work move <branch|num> # Move to a worktree by name or number
git work back # Return to main repository
git work finish [branch|num] # Remove worktree (current if not specified)# Create worktree for a new local branch
git work start feature-x
# Create worktree from a remote branch
git work start origin/feature-y
# Specify custom directory and base branch
git work start hotfix ../hotfix-dir main# Show all worktrees with numbers
git work list
# Show in machine-readable format
git work list --porcelain# Move to a specific worktree by name
git work move feature-x
# Move to a worktree by number (from git work list)
git work move 2# Navigate back from worktree to main repository
git work back# Remove current worktree and return to main
git work finish
# Remove a specific worktree by branch name
git work finish feature-x
# Remove a worktree by number (from git work list)
git work finish 2- Smart branch detection: Automatically detects if you're referencing a remote or local branch
- Auto-fetch: Fetches remote branches when needed
- Worktree creation: Creates a new worktree in
../<repo>--<branch>by default - Directory navigation: Automatically
cdinto the new worktree (only when not in tmux) - Tmux integration: Opens a new tmux pane in the worktree directory, keeping current pane unchanged
Shows all worktrees in the current repository with numbered entries for easy reference. Use --porcelain for machine-readable output compatible with git worktree list.
- Branch name mode: With a branch name, immediately switches to that worktree
- Number mode: With a number from
git work list, switches to the corresponding worktree (0-based) - Auto-navigation: Automatically changes directory to the selected worktree
- Tmux integration:
- Switches to existing pane if one exists with the branch name
- Opens new pane from main repository if no existing pane found
- Panes are titled with branch names for easy identification
- Navigation: Returns to the main repository from a worktree
- Directory detection: Uses standard naming pattern (
<repo>--<branch>) - Tmux integration: When in tmux, closes the current pane and returns to first pane
- Flexible removal: Remove current worktree (no args), by branch name, or by number
- Safety checks: Warns about uncommitted changes and unpushed commits
- Cleanup: Removes the worktree using
git worktree remove - Navigation: Automatically returns to the main repository
- Tmux integration: When removing current worktree in tmux, closes the pane and returns to first pane
# In your main repository
$ git work start feature-login
β Using origin/main as base branch
β Creating worktree with new branch 'feature-login' from 'origin/main'
β Worktree created at: ../myapp--feature-login
β Changed to worktree directory
β Successfully started work on branch 'feature-login'
Location: /Users/you/projects/myapp--feature-login$ git work start origin/bugfix-123
β Fetching remote branch: origin/bugfix-123
β Creating worktree with new branch 'bugfix-123' from 'origin/bugfix-123'
β Worktree created at: ../myapp--bugfix-123
β Changed to worktree directory
β Successfully started work on branch 'bugfix-123'
Location: /Users/you/projects/myapp--bugfix-123# List worktrees to see numbers
$ git work list
Git worktrees:
1) main (current)
Path: /Users/you/projects/myapp
2) feature-login
Path: /Users/you/projects/myapp--feature-login
3) bugfix-123
Path: /Users/you/projects/myapp--bugfix-123
# Move using number
$ git work move 2
β Moving to worktree for branch 'feature-login'
β Moved to worktree
Branch: feature-login
Location: /Users/you/projects/myapp--feature-login
# Or move using branch name
$ git work move bugfix-123
β Moving to worktree for branch 'bugfix-123'
β Moved to worktree
Branch: bugfix-123
Location: /Users/you/projects/myapp--bugfix-123# In a worktree directory
$ git work back
β Returning to main repository: myapp
β Back to main repository
Location: /Users/you/projects/myapp# In a worktree directory
$ git work finish
β Finishing work on branch 'feature-login'
β Removing worktree at: /Users/you/projects/myapp--feature-login
β Successfully finished work on branch 'feature-login'
Worktree removed: /Users/you/projects/myapp--feature-login
Current location: /Users/you/projects/myappThe tool creates worktrees with a consistent naming pattern:
projects/
βββ myapp/ # Main repository
βββ myapp--feature-login/ # Worktree for feature-login branch
βββ myapp--bugfix-123/ # Worktree for bugfix-123 branch
βββ myapp--release-v2/ # Worktree for release/v2 branch
- Git 2.5+ (for worktree support)
- Bash 4.0+
- Optional: tmux (for split-pane feature)
Git worktrees allow you to have multiple branches checked out simultaneously, which is perfect for:
- π§ Quick hotfixes without stashing current work
- π Code review while working on features
- π Parallel development on multiple features
- π Comparing implementations across branches
This tool simplifies worktree management and adds quality-of-life improvements like tmux integration.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT
Created with β€οΈ for the Git community