You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] specify custom worktree directory name independent of branch name #1982
When creating a new worktree with wt switch --create, the worktree directory name is always derived from the branch name. For branches using / separators (e.g. feature/JIRA-1234), the slash is sanitized to a dash, giving a directory like feature-JIRA-1234. There is no way to specify a different directory name on the command line.
If I want the directory to be named something descriptive like navigation-animation-refactor while the branch is feature/JIRA-1234, there's currently no way to do this.
Desired behavior
An option (e.g. --path or --name) that lets you specify the worktree directory path independently of the branch name:
This would create a branch called feature/JIRA-1234 with the worktree at a directory called navigation-animation-refactor — exactly what git worktree add already supports:
Today the only workaround is to drop down to git worktree add directly, which bypasses all of worktrunk's hooks, path templating, and shell integration.
Notes
The worktree-path config template controls the base path but not the per-invocation leaf name
Thanks for the suggestion! I searched the codebase and confirmed there's no existing flag to override the worktree directory name per-invocation on wt switch --create.
The closest related functionality is the worktree-path template in your config, which supports a replace filter for common patterns. For example, if your branches are always feature/JIRA-1234, you could strip the prefix:
That would give you repo.JIRA-1234 instead of repo.feature-JIRA-1234 — but it's a global rule, not a per-invocation override, so it doesn't address the core request (choosing an arbitrary descriptive name like navigation-animation-refactor at creation time).
I'll leave it for a maintainer to evaluate and prioritize.
changed the title [-]Feature request: specify custom worktree directory name independent of branch name[/-][+][Feature Request] specify custom worktree directory name independent of branch name[/+]on Apr 7, 2026
A core part of Worktrunk is making a reliable mapping between branches and worktrees. So the bar would be extremely high for us to offer a way to deviate from that.
(wt step promote is one (the only?) example of us doing that)
probably the best way would be to make an alias which ran git worktree move with a vars. @worktrunk-bot could you give an example / options of what that would look like?
and then, as ever — if something catches on, then we can consider how to update worktrunk towards it
wt switch --create feature/JIRA-1234
wt step rename --var name=navigation-animation-refactor
cd ../myrepo.navigation-animation-refactor # shell needs to follow the move
The {{ repo_path }}/../{{ repo }}.{{ name }} pattern mirrors the default worktree-path template, just with a custom leaf name instead of the sanitized branch. If you've customized worktree-path, the alias template should match your pattern.
Downside: After git worktree move, the current shell is still in the old (now-gone) directory, so you need a manual cd. The shell integration can't intercept this since the move happens inside the alias command.
Option 2: Shell function (handles the cd)
# In .zshrc / .bashrcwt-rename() {
local new_name="$1"local old_path="$(pwd)"local new_path="$(dirname "$old_path")/$new_name"
git worktree move "$old_path""$new_path"&&cd"$new_path"
}
This one handles the cd automatically since it's a shell function. Doesn't use wt template variables, but it doesn't need to — it just moves wherever you currently are.
I'd lean toward Option 2 for ergonomics — the cd issue with Option 1 adds friction. Option 1 is nice if you want the rename path to follow your worktree-path template pattern though.
The main argument for me is that I can organize my context as I see fit and Git natively already supports this behavior. To use only branch prefixes and issue numbers would result in a list of worktrees and directories like the following:
ha, totally understandable, and I empathize. I do think that part of the role of Worktrunk is to set some norms so coordination becomes easier, even if that makes some existing workflows a bit harder
I'm genuine in suggesting trying to build something outside the norms, and then seeing how that goes. Or use vars to set vars on the worktrees and then use the structured data about them; like a jira ticket no.
I would also like it if worktrunk could name the folders something completely irrelevant, like Conductor or Zed's built in worktrees. I personally don't need the branch name in the folder, it's included in my shell's statusline.
Something like {{ word }} and {{ city }} for use within the directory template using datasets similar to Zed/Conductor would be great.
i share the exact same pain as @christowiz and i also understand this functionality may be too specific to be implemented in worktrunk.
With multi AI agents working on separate worktrees, it can become difficult to keep track of what each branch is for. I wonder if there are alternative ways to help users identify the purpose of a branch more easily.
for example, perhaps wt list could display an optional description column, allowing users to attach a short label or note to each worktree.
+-----------------+--------------------------------+
| Branch | Description |
+-----------------+--------------------------------+
| fix/JIRA-1234 | Bug fix for production fire |
| feat/JIRA-1235 | New feature being implemented |
| chore/JIRA-1236 | Updating Node version v20->v22 |
+-----------------+--------------------------------+
Have you seen the summaries feature? It's not on by default because it fires off lots of Haiku calls, but it generates a summary of what's on the branch for wt switch or wt list --full. I think it's a bit hidden away atm, lmk any ideas for making it more available
I would be quite up for allowing custom vars in wt list. I worry a bit that it's a cooler feature to build than use; i.e. how helpful is it really? I could build something experimental if someone was confident they would use it. It would be something like:
in a list config, specify a templated string (allowing vars), the priority and the width (currently we want to paint the table skeleton really quickly, and we don't want shifting columns, so we need to know the width at create-time)
then wt list would get the vars for each branch and show that in the table
could also possibly be an templated expression / command
Have you seen the summaries feature? It's not on by default because it fires off lots of Haiku calls, but it generates a summary of what's on the branch for wt switch or wt list --full. I think it's a bit hidden away atm, lmk any ideas for making it more available
i didn't know about that! This is exactly what i was looking for!
I would be quite up for allowing custom vars in wt list. I worry a bit that it's a cooler feature to build than use; i.e. how helpful is it really?
i liked that idea. Maybe it doesn't need to be as flexible in the first version. A middle-ground solution you be to drop the --full flag and let users decide which columns they want to display in wt list:
[list]
summary = boolen
status = boolean
branch-name = boolean
path = boolean
ci = boolean
...
Just for the record because I'm not sure if I understand it correctly:
The initial feature request is not possible? The worktree directory must match the branch name via the worktree-path template?
I get that you could add additional info in the list but most other tools display the folder of the worktree as the name and I'm not always in charge of the branch names. Why do they need to be consistent if they can be mapped via git (git worktree list [--porcelain])?
Not quite — the directory name doesn't have to encode the branch. Two things have changed since the earlier discussion here.
1. Branch-free directory names are supported. The codename(n) filter (added in 0.49.0 via #2641) generates deterministic friendly names from the branch, so you can drop the branch out of the path entirely:
That gives myrepo.tenable-hookworm for feature/JIRA-9999 — stable across invocations, so it's the same directory every time.
2. For a one-off descriptive name, --config-set overrides the template for a single invocation — this is close to the --path flag the issue originally asked for:
$ wt --config-set 'worktree-path="{{ repo_path }}/../navigation-animation-refactor"' switch -c feature/JIRA-1234✓ Created branch feature/JIRA-1234 from main and worktree @ /tmp/scratch/navigation-animation-refactor
Afterwards plain wt switch feature/JIRA-1234 finds it, and wt list shows it, with no override needed — because addressing is branch-first and the path is only ever a location. The one caveat is wt step relocate, which reconciles worktrees against the template and would offer to move it back to myrepo.feature-JIRA-1234; the off-template name isn't recorded anywhere.
That caveat is also the answer to "why do they need to be consistent": they don't need to match, but the path does need to be derivable. Worktrunk computes the expected path from the template rather than reading it back from git, which is what lets it create a worktree at a known location, detect drift, and relocate. A per-invocation name that lives only in git's worktree list would be invisible to that. Whether it's worth storing such a name is a maintainer call — @max-sixty already set the bar for deviating from the branch↔worktree mapping above.
Verification
Tested against wt v0.72.0-22-g8bf8ae44a in a scratch repo:
wt --config-set 'worktree-path="…/navigation-animation-refactor"' switch -c feature/JIRA-1234 → directory navigation-animation-refactor, git branch --show-current in it → feature/JIRA-1234.
Plain wt switch feature/JIRA-1234 (no override) → ○ Switched to worktree for feature/JIRA-1234 @ /tmp/scratch/navigation-animation-refactor.
codename(2) on feature/JIRA-9999 → myrepo.tenable-hookworm, identical on a second run.
Source: template expansion and the filter registry in src/config/expansion.rs; creation-time validation checks only path occupancy, never a branch/path relationship (switch.rs); branch-first resolution in worktrees.rs.
I'm fine with keeping the default behaviour. The cli could provide an additional option (eg: wt switch --path <folder-name> [--create <branchname>]) that allows creation and retrieval of worktrees with custom path names. Just git for-each-ref --format='%(worktreepath)' "refs/heads/<branch-name>" instead of worktree-path.
Worth splitting your two halves, because retrieval is already there and creation nearly is.
Retrieval by path already works today. Every argument that names a worktree also accepts that worktree's own path — resolved after the branch, so a directory can never shadow a branch sharing its name (docs). Against the custom-named worktree from my last comment:
$ wt switch ../navigation-animation-refactor○ Switched to worktree for feature/JIRA-1234 @ /tmp/scratch/navigation-animation-refactor
Absolute paths and ~-relative paths work the same way; relative ones resolve against -C. The one shape that doesn't is a bare leaf name — wt switch navigation-animation-refactor is read as a branch and fails with No branch named …, since branch-first ordering is what stops a stray directory from hijacking a branch name.
Creation is covered too, just verbosely — the --config-set recipe above. So a --path flag wouldn't unlock anything new; it would be shorthand for that plus, presumably, persistence.
That persistence is the real content of the request, and it's why this isn't a small flag. Worktrunk computes the expected path from the template rather than reading it back from git — that's what lets it create at a known location, detect drift, and offer wt step relocate. An off-template name isn't recorded anywhere, so relocate still offers to move it back:
$ wt step relocate --dry-run○ 1 worktree would be relocated: feature/JIRA-1234: /tmp/scratch/navigation-animation-refactor → /tmp/scratch/myrepo.feature-JIRA-1234
A native --path would have to store the chosen name in per-worktree state and teach relocate to honour it — a new piece of persisted state per worktree, not just a flag. That's a maintainer call, and @max-sixty has set the bar for deviating from the branch↔worktree mapping above.
Verification
Tested against a local build at 8bf8ae4 in a scratch repo (/tmp/scratch/myrepo, worktree created via wt --config-set 'worktree-path="{{ repo_path }}/../navigation-animation-refactor"' switch -c feature/JIRA-1234):
You're right, and I overstated it last time. I wrote that worktrunk "computes the expected path from the template rather than reading it back from git" — that holds only for creation, wt step relocate, and display naming. Resolution and listing already read paths back from git, which is exactly what you're proposing.
The mechanism is git worktree list --porcelain rather than for-each-ref %(worktreepath), but it's the same information, and a superset: the ref-keyed atom can't express a detached worktree (no branch ref to hang the path on) or two checkouts of one branch, both of which the porcelain list carries.
So the retrieval half is already implemented — wt switch short-circuits on a resolved worktree before it ever expands the template. The code comment calls the template the slow path outright: "Resolving before the path template is also the fast path: an existing worktree answers without the ~7 git commands compute_worktree_path runs."
And the display shape you're after largely exists too. A worktree whose path is off-template gets named by its directory, not its branch:
$ wt step for-each -- git rev-parse --abbrev-ref HEAD◎ Running in main...◎ Running in feature/JIRA-5678... # on-template → branch name◎ Running in navigation-animation-refactor (on feature/JIRA-1234)... # off-template → dir name
What's genuinely left is narrower than a --path flag would suggest, and it splits the same way your comment does:
Creation has to compute a path — there's nothing to read back yet, since the worktree doesn't exist. --config-set already covers this per-invocation, so --path would be shorthand rather than new capability.
wt step relocate reconciles against the template, so it still offers to move an off-template worktree back. This is the one place a custom name would have to be persisted rather than read from git — git records where the worktree is, but not that you chose that name, so relocate can't tell an intentional name from drift.
So the open design question isn't retrieval at all; it's whether a per-worktree chosen path gets recorded so relocate leaves it alone. That's a maintainer call, and @max-sixty set the bar for it earlier in the thread.
Verification
Local build at 8bf8ae44a, scratch repo at /tmp/scratch/myrepo, worktree created with wt --config-set 'worktree-path="{{ repo_path }}/../navigation-animation-refactor"' switch -c feature/JIRA-1234.
Retrieval with no override in effect — both selectors land on the off-template path:
Command
Result
wt switch feature/JIRA-1234
Worktree for feature/JIRA-1234 @ /tmp/scratch/navigation-animation-refactor
%(worktreepath) vs the porcelain list (git 2.54.0), showing the two shapes the ref-keyed atom drops:
$ git for-each-ref --format='%(refname:short) -> [%(worktreepath)]' refs/heads/feature/JIRA-1234 -> [/tmp/feref/navigation-animation-refactor]main -> [/tmp/feref/repo]no-worktree -> []
$ git worktree list --porcelain # the detached worktree has no refs/heads/ row aboveworktree /tmp/feref/detached-wtHEAD 3d4b709f7fca0aba7a8ef1e53f8754b1247151a0detached
Source: worktree enumeration reads the porcelain list in Repository::list_worktrees; wt switch resolves first and only reaches the template for creation (switch.rs Phase 2 → Phase 3, where line 887 is commented "Compute expected path (only needed for create)"); the directory-name display form is worktree_display_name. Those three call sites plus relocate.rs are the only consumers of compute_worktree_path.
So to resolve this issue, you would advise the author to create an alias or shell script with wt --config-set ... for creation and wt switch <relative-path> for switching? Give an example.
Is there a feature that would be broken with this workflow? What else is the path mapping used for?
Yes, and it's one alias rather than two — --create can ride in {{ args }}, so the same alias covers creation and materialising an existing branch:
# ~/.config/worktrunk/config.toml
[aliases]
new = '''wt --config-set 'worktree-path="{{ repo_path }}/../{{ name }}"' switch {{ args }}'''
$ wt new -c feature/JIRA-1234 --name=navigation-animation-refactor✓ Created branch feature/JIRA-1234 from main and worktree @ /tmp/scratch/navigation-animation-refactor
$ wt new existing-branch --name=some-custom-dir # no -c: existing branch, custom dir✓ Created worktree for existing-branch @ /tmp/scratch/some-custom-dir
--name=… binds to {{ name }} and everything else forwards to {{ args }} via smart routing, so flags like -c and --yes pass straight through. {{ repo_path }}/../{{ name }} mirrors the shape of the default worktree-path, minus the {{ repo }}. prefix and branch leaf — match your own template if you've customised it.
And it cds. I got this wrong earlier in the thread when I said a shell function was needed — that was about git worktree move, not wt switch. wt switch, wt merge, and wt remove propagate the directory change to the parent shell even when invoked from an alias; I verified wt new … lands you in the new worktree. Afterwards plain wt switch feature/JIRA-1234 and wt switch ../navigation-animation-refactor both work with no override.
What breaks
One thing: wt step relocate (experimental) reconciles worktrees against the template, so it offers to move every custom-named worktree back to myrepo.feature-JIRA-1234. Nothing runs it automatically — it's an explicit wt step invocation — so the workflow is safe as long as you don't run it. That's the persistence gap from my last comment: git records where the worktree is, not that you chose the name.
Everything else I tried works unchanged: hooks fire with the custom {{ worktree_path }}, wt merge --yes merges and cleans up the custom directory and cds back to main, wt remove accepts either the branch or the path.
Cosmetically, wt list marks each off-template worktree with a dim-yellow ⚑ — and, as a side effect, turns the Path column on, since a path that doesn't follow the template carries information the branch column doesn't. For this use case that's arguably the feature you wanted:
Branch Status HEAD± main↕ main…± Remote⇅ Path Commit Age Message
@ main ^ . aa500db now init
+ feature/JIRA-5678 ⚑_ ../dark-mode-toggle aa500db now init
+ feature/JIRA-1234 ⚑_ ../navigation-animation-refactor aa500db now init
○ Showing 3 worktrees
What the path template is used for
compute_worktree_path — the only thing that expands worktree-path — has exactly four call sites, which is the whole surface a custom name touches:
Consumer
Effect on a custom-named worktree
Creation (wt switch -c)
The only place it's load-bearing — there's no worktree to read back yet, so a path must be computed. This is what the alias overrides.
wt step relocate
Sees the mismatch as drift; offers to move it back.
Display naming (worktree_display_name)
Off-template worktrees are named by directory: navigation-animation-refactor (on feature/JIRA-1234) in wt step for-each.
wt list state flag
Sets ⚑ and worktree.state: "branch_worktree_mismatch" in --format=json; makes the Path column informative.
Resolution, listing, merge, remove, and hooks never consult it — they read paths back from git worktree list --porcelain, exactly as you proposed.
Verification
Local build at 8bf8ae44a, scratch repo /tmp/scratch/myrepo (default branch main), bash with shell integration installed, the alias above as the only user config.
Alias expansion:
$ wt config alias dry-run new -- -c feature/JIRA-7777 --name=api-rate-limits○ Alias new (user) would run: # bound: name=api-rate-limits # args: -c feature/JIRA-7777 wt --config-set 'worktree-path="/tmp/scratch/myrepo/../api-rate-limits"' switch -c feature/JIRA-7777
Scenario
Result
wt new -c feature/JIRA-5678 --name=dark-mode-toggle in bash
worktree at /tmp/scratch/dark-mode-toggle; $PWD after → same path (cd propagated through the alias)
wt switch feature/JIRA-5678 (no override)
resolves → /tmp/scratch/dark-mode-toggle
wt switch ../navigation-animation-refactor
resolves → feature/JIRA-1234
wt new existing-branch --name=some-custom-dir
✓ Created worktree for existing-branch @ /tmp/scratch/some-custom-dir
"worktree": {"state": "branch_worktree_mismatch", "detached": false} on both custom rows
Failure modes, all safe:
$ wt new feature/JIRA-9999 # --name omitted✗ Failed to expand new: undefined value @ line 1 wt --config-set 'worktree-path="{{ repo_path }}/../{{ name }}"' switch {{ args }}↳ Available variables: args, branch, cwd, main_worktree, repo, repo_path, repo_root, worktree, worktree_name, worktree_path
$ wt new -c feature/JIRA-8888 --name=dark-mode-toggle # name already taken✗ Cannot switch to feature/JIRA-8888 — there's a worktree at the expected path /tmp/scratch/dark-mode-toggle on branch feature/JIRA-5678
$ wt new -c existing-branch --name=some-custom-dir # branch already exists✗ Branch existing-branch already exists↳ To switch to the existing branch, run without --create: wt switch existing-branch
$ wt new -c feat/JIRA-1234/dark-mode --name=dark-mode
That creates branch feat/JIRA-1234/dark-mode in a dark-mode directory and cds into it.
The switching half you describe doesn't work yet, though:
Tab completion offers branch names only.wt switch dark<TAB> offers nothing, since completion only matches feat/JIRA-1234/dark-mode and main.
A bare directory name doesn't resolve.wt switch dark-mode fails with ✗ No branch named dark-mode, because a path selector is resolved relative to the current directory. You'd have to type wt switch ../dark-mode.
So the gap your comment points to is completion and lookup by directory name, not creation. Offering off-template worktrees by their directory name in completion and resolution would be a much smaller change than a per-worktree --name, because git already records the path. Whether to do it is up to @max-sixty, who set a high bar for departing from the branch↔worktree mapping above.
Verification
Local build at aff6bc3b1, scratch repo with the new alias as the only user config. From the main worktree:
$ wt new -c feat/JIRA-1234/dark-mode --name=dark-mode --yes
# worktree created at <scratch>/dark-mode
$ wt switch dark-mode✗ No branch named dark-mode
$ wt switch ../dark-mode▲ Worktree for feat/JIRA-1234/dark-mode @ <scratch>/dark-mode ...
$ COMPLETE=bash ... wt -- wt switch ""# bash completion candidatesfeat/JIRA-1234/dark-modemain
wt switch completion goes through BranchCompleter (src/completion.rs), which lists branches only.
Opened #4317: wt switch --create feat/JIRA-1234/dark-mode --path ../dark-mode. Relative paths resolve from the current directory, as with git worktree add, and --path also works for an existing branch that has no worktree yet. The PR raises one decision for you: resolve from the cwd (what it does now) or from the template's parent directory.
Activity
worktrunk-bot commentedon Apr 7, 2026
Thanks for the suggestion! I searched the codebase and confirmed there's no existing flag to override the worktree directory name per-invocation on
wt switch --create.The closest related functionality is the
worktree-pathtemplate in your config, which supports areplacefilter for common patterns. For example, if your branches are alwaysfeature/JIRA-1234, you could strip the prefix:That would give you
repo.JIRA-1234instead ofrepo.feature-JIRA-1234— but it's a global rule, not a per-invocation override, so it doesn't address the core request (choosing an arbitrary descriptive name likenavigation-animation-refactorat creation time).I'll leave it for a maintainer to evaluate and prioritize.
[-]Feature request: specify custom worktree directory name independent of branch name[/-][+][Feature Request] specify custom worktree directory name independent of branch name[/+]max-sixty commentedon Apr 7, 2026
A core part of Worktrunk is making a reliable mapping between branches and worktrees. So the bar would be extremely high for us to offer a way to deviate from that.
(
wt step promoteis one (the only?) example of us doing that)probably the best way would be to make an alias which ran
git worktree movewith a vars. @worktrunk-bot could you give an example / options of what that would look like?and then, as ever — if something catches on, then we can consider how to update worktrunk towards it
worktrunk-bot commentedon Apr 7, 2026
Here are a couple of options:
Option 1:
wt stepalias (simplest)Usage:
The
{{ repo_path }}/../{{ repo }}.{{ name }}pattern mirrors the defaultworktree-pathtemplate, just with a custom leaf name instead of the sanitized branch. If you've customizedworktree-path, the alias template should match your pattern.Downside: After
git worktree move, the current shell is still in the old (now-gone) directory, so you need a manualcd. The shell integration can't intercept this since the move happens inside the alias command.Option 2: Shell function (handles the
cd)Usage:
This one handles the
cdautomatically since it's a shell function. Doesn't usewttemplate variables, but it doesn't need to — it just moves wherever you currently are.I'd lean toward Option 2 for ergonomics — the
cdissue with Option 1 adds friction. Option 1 is nice if you want the rename path to follow yourworktree-pathtemplate pattern though.max-sixty commentedon Apr 7, 2026
ok. I think we could combine these two into an alias:
...but fair point on the
cd; that does somewhat require a shell functionworktrunk-bot commentedon Apr 7, 2026
christowiz commentedon Apr 8, 2026
I guess this is a "me" problem ;)
The main argument for me is that I can organize my context as I see fit and Git natively already supports this behavior. To use only branch prefixes and issue numbers would result in a list of worktrees and directories like the following:
There is a simple workaround which is to adjust my workflow start adding my custom context to the branch names:
It is additional noise unfortunately
max-sixty commentedon Apr 8, 2026
ha, totally understandable, and I empathize. I do think that part of the role of Worktrunk is to set some norms so coordination becomes easier, even if that makes some existing workflows a bit harder
I'm genuine in suggesting trying to build something outside the norms, and then seeing how that goes. Or use
varsto set vars on the worktrees and then use the structured data about them; like a jira ticket no.endigma commentedon Apr 29, 2026
I would also like it if worktrunk could name the folders something completely irrelevant, like Conductor or Zed's built in worktrees. I personally don't need the branch name in the folder, it's included in my shell's statusline.
Something like
{{ word }}and{{ city }}for use within the directory template using datasets similar to Zed/Conductor would be great.endigma commentedon May 9, 2026
I implemented by own suggestion in #2641, you can now have random human readable directories instead of branch name.
denisdifazio commentedon May 27, 2026
i share the exact same pain as @christowiz and i also understand this functionality may be too specific to be implemented in worktrunk.
With multi AI agents working on separate worktrees, it can become difficult to keep track of what each branch is for. I wonder if there are alternative ways to help users identify the purpose of a branch more easily.
for example, perhaps
wt listcould display an optionaldescriptioncolumn, allowing users to attach a short label or note to each worktree.max-sixty commentedon May 28, 2026
yes @denisdifazio !
Two things:
wt switchorwt list --full. I think it's a bit hidden away atm, lmk any ideas for making it more availablewt list. I worry a bit that it's a cooler feature to build than use; i.e. how helpful is it really? I could build something experimental if someone was confident they would use it. It would be something like:listconfig, specify a templated string (allowingvars), the priority and the width (currently we want to paint the table skeleton really quickly, and we don't want shifting columns, so we need to know the width at create-time)wt listwould get the vars for each branch and show that in the tabledenisdifazio commentedon May 28, 2026
i didn't know about that! This is exactly what i was looking for!
thanks @max-sixty
i liked that idea. Maybe it doesn't need to be as flexible in the first version. A middle-ground solution you be to drop the
--fullflag and let users decide which columns they want to display inwt list:feat(list): custom template columns and cached PR numbers in the pick…
max-sixty commentedon Jun 29, 2026
to round this out, this is now released!
krsilas commentedon Aug 11, 2026
Just for the record because I'm not sure if I understand it correctly:
The initial feature request is not possible? The worktree directory must match the branch name via the worktree-path template?
I get that you could add additional info in the list but most other tools display the folder of the worktree as the name and I'm not always in charge of the branch names. Why do they need to be consistent if they can be mapped via git (
git worktree list [--porcelain])?worktrunk-bot commentedon Aug 11, 2026
Not quite — the directory name doesn't have to encode the branch. Two things have changed since the earlier discussion here.
1. Branch-free directory names are supported. The
codename(n)filter (added in 0.49.0 via #2641) generates deterministic friendly names from the branch, so you can drop the branch out of the path entirely:That gives
myrepo.tenable-hookwormforfeature/JIRA-9999— stable across invocations, so it's the same directory every time.2. For a one-off descriptive name,
--config-setoverrides the template for a single invocation — this is close to the--pathflag the issue originally asked for:Afterwards plain
wt switch feature/JIRA-1234finds it, andwt listshows it, with no override needed — because addressing is branch-first and the path is only ever a location. The one caveat iswt step relocate, which reconciles worktrees against the template and would offer to move it back tomyrepo.feature-JIRA-1234; the off-template name isn't recorded anywhere.That caveat is also the answer to "why do they need to be consistent": they don't need to match, but the path does need to be derivable. Worktrunk computes the expected path from the template rather than reading it back from git, which is what lets it create a worktree at a known location, detect drift, and relocate. A per-invocation name that lives only in git's worktree list would be invisible to that. Whether it's worth storing such a name is a maintainer call — @max-sixty already set the bar for deviating from the branch↔worktree mapping above.
Verification
Tested against
wt v0.72.0-22-g8bf8ae44ain a scratch repo:wt --config-set 'worktree-path="…/navigation-animation-refactor"' switch -c feature/JIRA-1234→ directorynavigation-animation-refactor,git branch --show-currentin it →feature/JIRA-1234.wt switch feature/JIRA-1234(no override) →○ Switched to worktree for feature/JIRA-1234 @ /tmp/scratch/navigation-animation-refactor.wt step relocate --dry-run→feature/JIRA-1234: /tmp/scratch/navigation-animation-refactor → /tmp/scratch/myrepo.feature-JIRA-1234.codename(2)onfeature/JIRA-9999→myrepo.tenable-hookworm, identical on a second run.Source: template expansion and the filter registry in
src/config/expansion.rs; creation-time validation checks only path occupancy, never a branch/path relationship (switch.rs); branch-first resolution inworktrees.rs.krsilas commentedon Aug 11, 2026
I'm fine with keeping the default behaviour. The cli could provide an additional option (eg:
wt switch --path <folder-name> [--create <branchname>]) that allows creation and retrieval of worktrees with custom path names. Justgit for-each-ref --format='%(worktreepath)' "refs/heads/<branch-name>"instead of worktree-path.worktrunk-bot commentedon Aug 11, 2026
Worth splitting your two halves, because retrieval is already there and creation nearly is.
Retrieval by path already works today. Every argument that names a worktree also accepts that worktree's own path — resolved after the branch, so a directory can never shadow a branch sharing its name (docs). Against the custom-named worktree from my last comment:
Absolute paths and
~-relative paths work the same way; relative ones resolve against-C. The one shape that doesn't is a bare leaf name —wt switch navigation-animation-refactoris read as a branch and fails withNo branch named …, since branch-first ordering is what stops a stray directory from hijacking a branch name.Creation is covered too, just verbosely — the
--config-setrecipe above. So a--pathflag wouldn't unlock anything new; it would be shorthand for that plus, presumably, persistence.That persistence is the real content of the request, and it's why this isn't a small flag. Worktrunk computes the expected path from the template rather than reading it back from git — that's what lets it create at a known location, detect drift, and offer
wt step relocate. An off-template name isn't recorded anywhere, so relocate still offers to move it back:A native
--pathwould have to store the chosen name in per-worktree state and teach relocate to honour it — a new piece of persisted state per worktree, not just a flag. That's a maintainer call, and @max-sixty has set the bar for deviating from the branch↔worktree mapping above.Verification
Tested against a local build at 8bf8ae4 in a scratch repo (
/tmp/scratch/myrepo, worktree created viawt --config-set 'worktree-path="{{ repo_path }}/../navigation-animation-refactor"' switch -c feature/JIRA-1234):wt switch /tmp/scratch/navigation-animation-refactorfeature/JIRA-1234wt switch ../navigation-animation-refactorfeature/JIRA-1234wt switch navigation-animation-refactor✗ No branch named navigation-animation-refactorwt switch feature/JIRA-1234wt listPathcolumn shows../navigation-animation-refactorwt step relocate --dry-runmyrepo.feature-JIRA-1234Resolution ladder (branch → path → verdict) in
Repository::resolve_worktree/resolve_selector; the same wording is the primary source for the docs page atsrc/cli/mod.rs.worktrunk-bot commentedon Aug 11, 2026
You're right, and I overstated it last time. I wrote that worktrunk "computes the expected path from the template rather than reading it back from git" — that holds only for creation,
wt step relocate, and display naming. Resolution and listing already read paths back from git, which is exactly what you're proposing.The mechanism is
git worktree list --porcelainrather thanfor-each-ref %(worktreepath), but it's the same information, and a superset: the ref-keyed atom can't express a detached worktree (no branch ref to hang the path on) or two checkouts of one branch, both of which the porcelain list carries.So the retrieval half is already implemented —
wt switchshort-circuits on a resolved worktree before it ever expands the template. The code comment calls the template the slow path outright: "Resolving before the path template is also the fast path: an existing worktree answers without the ~7 git commandscompute_worktree_pathruns."And the display shape you're after largely exists too. A worktree whose path is off-template gets named by its directory, not its branch:
What's genuinely left is narrower than a
--pathflag would suggest, and it splits the same way your comment does:--config-setalready covers this per-invocation, so--pathwould be shorthand rather than new capability.wt step relocatereconciles against the template, so it still offers to move an off-template worktree back. This is the one place a custom name would have to be persisted rather than read from git — git records where the worktree is, but not that you chose that name, so relocate can't tell an intentional name from drift.So the open design question isn't retrieval at all; it's whether a per-worktree chosen path gets recorded so relocate leaves it alone. That's a maintainer call, and @max-sixty set the bar for it earlier in the thread.
Verification
Local build at
8bf8ae44a, scratch repo at/tmp/scratch/myrepo, worktree created withwt --config-set 'worktree-path="{{ repo_path }}/../navigation-animation-refactor"' switch -c feature/JIRA-1234.Retrieval with no override in effect — both selectors land on the off-template path:
wt switch feature/JIRA-1234Worktree for feature/JIRA-1234 @ /tmp/scratch/navigation-animation-refactorwt switch ../navigation-animation-refactorwt listPathcolumn →../navigation-animation-refactorwt step relocate --dry-runfeature/JIRA-1234: /tmp/scratch/navigation-animation-refactor → /tmp/scratch/myrepo.feature-JIRA-1234%(worktreepath)vs the porcelain list (git 2.54.0), showing the two shapes the ref-keyed atom drops:Source: worktree enumeration reads the porcelain list in
Repository::list_worktrees;wt switchresolves first and only reaches the template for creation (switch.rsPhase 2 → Phase 3, where line 887 is commented "Compute expected path (only needed for create)"); the directory-name display form isworktree_display_name. Those three call sites plusrelocate.rsare the only consumers ofcompute_worktree_path.krsilas commentedon Aug 11, 2026
So to resolve this issue, you would advise the author to create an alias or shell script with
wt --config-set ...for creation andwt switch <relative-path>for switching? Give an example.Is there a feature that would be broken with this workflow? What else is the path mapping used for?
worktrunk-bot commentedon Aug 11, 2026
Yes, and it's one alias rather than two —
--createcan ride in{{ args }}, so the same alias covers creation and materialising an existing branch:--name=…binds to{{ name }}and everything else forwards to{{ args }}via smart routing, so flags like-cand--yespass straight through.{{ repo_path }}/../{{ name }}mirrors the shape of the defaultworktree-path, minus the{{ repo }}.prefix and branch leaf — match your own template if you've customised it.And it cds. I got this wrong earlier in the thread when I said a shell function was needed — that was about
git worktree move, notwt switch.wt switch,wt merge, andwt removepropagate the directory change to the parent shell even when invoked from an alias; I verifiedwt new …lands you in the new worktree. Afterwards plainwt switch feature/JIRA-1234andwt switch ../navigation-animation-refactorboth work with no override.What breaks
One thing:
wt step relocate(experimental) reconciles worktrees against the template, so it offers to move every custom-named worktree back tomyrepo.feature-JIRA-1234. Nothing runs it automatically — it's an explicitwt stepinvocation — so the workflow is safe as long as you don't run it. That's the persistence gap from my last comment: git records where the worktree is, not that you chose the name.Everything else I tried works unchanged: hooks fire with the custom
{{ worktree_path }},wt merge --yesmerges and cleans up the custom directory and cds back to main,wt removeaccepts either the branch or the path.Cosmetically,
wt listmarks each off-template worktree with a dim-yellow⚑— and, as a side effect, turns thePathcolumn on, since a path that doesn't follow the template carries information the branch column doesn't. For this use case that's arguably the feature you wanted:What the path template is used for
compute_worktree_path— the only thing that expandsworktree-path— has exactly four call sites, which is the whole surface a custom name touches:wt switch -c)wt step relocateworktree_display_name)navigation-animation-refactor (on feature/JIRA-1234)inwt step for-each.wt liststate flag⚑andworktree.state: "branch_worktree_mismatch"in--format=json; makes thePathcolumn informative.Resolution, listing, merge, remove, and hooks never consult it — they read paths back from
git worktree list --porcelain, exactly as you proposed.Verification
Local build at
8bf8ae44a, scratch repo/tmp/scratch/myrepo(default branchmain), bash with shell integration installed, the alias above as the only user config.Alias expansion:
wt new -c feature/JIRA-5678 --name=dark-mode-togglein bash/tmp/scratch/dark-mode-toggle;$PWDafter → same path (cd propagated through the alias)wt switch feature/JIRA-5678(no override)/tmp/scratch/dark-mode-togglewt switch ../navigation-animation-refactorfeature/JIRA-1234wt new existing-branch --name=some-custom-dir✓ Created worktree for existing-branch @ /tmp/scratch/some-custom-dirpost-starthook in project config◎ Running post-start: greet (project) @ /tmp/scratch/search-indexingwt merge --yesfrom/tmp/scratch/payments-retry$PWDafter →/tmp/scratch/myrepowt remove existing-branch --yes/wt remove ../dark-mode-toggle --yeswt step relocate --dry-runmyrepo.feature-JIRA-*wt list --format=json"worktree": {"state": "branch_worktree_mismatch", "detached": false}on both custom rowsFailure modes, all safe:
Source: the four
compute_worktree_pathcall sites areswitch.rs:888(guarded by the create path),relocate.rs:203, and — viais_worktree_at_expected_path—worktree_display_nameandlist/collect/mod.rs:1150. ThePath-column trigger islayout.rs:1216; the state-symbol priority isitem.rs:31-43.kcrwfrd commentedon Sep 28, 2026
+1, I would really like to be able to be able to do something like this
To create a branch
feat/JIRA-1234/dark-modebut with the worktree directory/name asdark-mode, to make subsequent switching faster:# much easier to hit tab at this point and autocomplete to `wt switch dark-mode` wt switch darkand make navigating the file system much easier, too.
worktrunk-bot commentedon Sep 28, 2026
@kcrwfrd The creation half works today with the
newalias from earlier in the thread:$ wt new -c feat/JIRA-1234/dark-mode --name=dark-modeThat creates branch
feat/JIRA-1234/dark-modein adark-modedirectory and cds into it.The switching half you describe doesn't work yet, though:
wt switch dark<TAB>offers nothing, since completion only matchesfeat/JIRA-1234/dark-modeandmain.wt switch dark-modefails with✗ No branch named dark-mode, because a path selector is resolved relative to the current directory. You'd have to typewt switch ../dark-mode.So the gap your comment points to is completion and lookup by directory name, not creation. Offering off-template worktrees by their directory name in completion and resolution would be a much smaller change than a per-worktree
--name, because git already records the path. Whether to do it is up to @max-sixty, who set a high bar for departing from the branch↔worktree mapping above.Verification
Local build at
aff6bc3b1, scratch repo with thenewalias as the only user config. From the main worktree:wt switchcompletion goes throughBranchCompleter(src/completion.rs), which lists branches only.max-sixty commentedon Sep 29, 2026
ok, I think maybe it's time.
let's add a --path option @worktrunk-bot
worktrunk-bot commentedon Sep 29, 2026
Opened #4317:
wt switch --create feat/JIRA-1234/dark-mode --path ../dark-mode. Relative paths resolve from the current directory, as withgit worktree add, and--pathalso works for an existing branch that has no worktree yet. The PR raises one decision for you: resolve from the cwd (what it does now) or from the template's parent directory.feat(switch): add --path to create a worktree outside the worktree-pa…