Add global worktree directory support #345
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm mainly looking for feedback. This is my first time working in a Rust codebase 🥲
Screen.Recording.2025-12-31.at.11.26.52.PM.mov
Summary
Add support for managing worktrees across multiple projects from a central directory.
global-worktree-dirplaces all worktrees in one location using{project}.{branch}namingwt list --globaldiscovers and lists worktrees across all projects, grouped by repositoryMotivation
When working on multiple projects, I wanted to keep all worktrees in a single directory (
~/worktrees/) rather than scattered as siblings to each repo. This makes it easy to see everything at a glance and keeps project directories clean.Before:
After (with
global-worktree-dir = "~/worktrees"):Usage
Design decisions
.gitfiles (not directories) to find linked worktrees, then groups by parent repositoryproject_identifier()(e.g.,worktrunknotgithub.com/user/worktrunk) for readable directory names--globalconflicts with--branches/--remotessince those are repo-specificTest plan
wt list --globalwhen not configured → helpful error messagewt list --globalwhen directory doesn't exist → errorwt list --globalwith empty directory → "No worktrees found"projectandproject_pathfields