Syntax
Arguments
This command takes no arguments.Behavior
Thelist command displays comprehensive information about all worktrees:
1. Worktree Discovery
- Locates the repository root using
resolve_repo_root - Accesses the bare repository at
.bare/ - Queries Git for all registered worktrees
functions/worktree.zsh:61-65
2. Information Displayed
For each worktree, Git provides:- Worktree path: Full filesystem path to the worktree directory
- Branch name: The currently checked out branch
- Commit hash: Short hash of the current HEAD commit
- Commit message: First line of the commit message
3. Bare Repository Entry
The output includes the bare repository itself (.bare/):
- Listed as
(bare)instead of a branch name - Not typically used for direct work
- Can be ignored in most workflows
Output Format
Git’s worktree list displays in this format:- Absolute path to worktree
- Commit hash (7 characters)
- Branch name in brackets
- Commit message (first line)
Examples
List All Worktrees
Using Short Alias
functions/worktree.zsh:7
Check Before Adding
Count Worktrees
Error Cases
Repository Root Not Found
functions/worktree.zsh:62-63
No Worktrees Exist
If only the bare repository exists (no worktrees created yet):repo wt add to create worktrees.
Tips and Best Practices
Quick Status Check
Uselist to get an overview of all active work:
Integration with Other Commands
Combine withgrep to find specific worktrees:
Identifying Default Branch
The worktree for your default branch (main/master) is typically:- Listed first after the bare repository
- Has a branch name of
[main]or[master] - Cannot be removed with
repo wt rmorrepo wt clean
Detecting Stale Worktrees
Look for worktrees with:- Very old commit dates
- Branches that have been merged
- Work that is no longer relevant
repo wt clean to remove multiple stale worktrees at once.
Filesystem Paths
Worktree paths shown are absolute, making it easy to:- Navigate directly:
cd /path/from/output - Reference in scripts
- Use with other tools
repo wt go <branch> for navigation to ensure proper hooks run.
Bare Repository
The(bare) entry in the output:
- Is the actual Git repository storage
- Should not be modified directly
- Can be safely ignored in day-to-day work
- Is used internally by all worktree commands
See Also
- repo wt add - Create new worktrees
- repo wt go - Navigate to a worktree
- repo wt rm - Remove a specific worktree
- repo wt clean - Remove all non-default worktrees