Syntax
Arguments
<branch>(required): The branch name of the worktree to navigate to
Behavior
Thego command provides smart navigation to worktrees:
1. Branch Name Resolution
- Takes the branch name as input (not the full path)
- Constructs the worktree path:
<repo-root>/<branch>/ - Validates that the worktree exists
functions/worktree.zsh:107-110
2. Worktree Validation
Before navigation:- Checks if the worktree directory exists
- If not found, displays an error and lists available worktrees
- Provides helpful context for correcting the branch name
functions/worktree.zsh:112-117
3. Post-Navigation Hooks
After validation, thepost_wt_go hook is called:
- Changes to the worktree directory
- May activate environment-specific configuration
- May display custom information about the worktree
- Ensures proper shell environment setup
functions/worktree.zsh:119
Why Use go Instead of cd?
While you can manually cd to a worktree path, using repo wt go provides:
- Path Resolution: No need to remember full paths or repository structure
- Validation: Ensures the worktree exists before attempting navigation
- Hooks: Runs environment setup that may be required for the project
- Convenience: Simple branch name instead of full filesystem path
- Error Handling: Helpful messages if the worktree doesn’t exist
Examples
Navigate to Existing Worktree
functions/worktree.zsh:119
Navigate to Default Branch
Quick Branch Switching
Combine with Other Commands
Error Cases
Missing Branch Name
functions/worktree.zsh:101-105
Worktree Not Found
functions/worktree.zsh:112-117
Repository Root Not Found
functions/worktree.zsh:108-109
Tips and Best Practices
Use Tab Completion
If your shell is configured with tab completion for Repo Manager:Check Available Worktrees First
If you’re unsure which worktrees exist:Create and Navigate in One Flow
Rapid Context Switching
Worktrees eliminate the need to stash changes:Branch Name Format
The branch name used withgo should match:
- The directory name under the repository root
- The branch name used when creating the worktree
- The branch name shown in
repo wt listoutput (without brackets)
repo wt list shows:
Error Recovery
If you get a “Worktree not found” error:- Check the exact branch name with
repo wt list - Verify the worktree wasn’t removed
- Create the worktree if needed with
repo wt add
Shell Environment
Thepost_wt_go hook may:
- Activate project-specific environments (Node.js version, Python virtualenv, etc.)
- Load environment variables
- Display project status or reminders
- Run custom setup scripts
repo wt go is preferred over manual cd commands.
See Also
- repo wt list - View all worktrees
- repo wt add - Create new worktrees
- repo wt rm - Remove worktrees
- Worktree Overview - Understanding worktrees