Skip to content

Preserve branch name slashes as subdirectories in worktree path #118

@jamisonbryant

Description

@jamisonbryant

Summary

When a branch name contains slashes (e.g., feature/my-thing, issue/fix-login), sanitize_branch_name() replaces / with -, producing a flat directory like worktrees/feature-my-thing. I'd like worktrees to preserve the slash as a directory separator instead, producing worktrees/feature/my-thing.

Context

Many teams use hierarchical branch naming conventions (feature/, issue/, hot-fix/, etc.). With the current behavior, all worktrees are dumped into a single flat directory regardless of branch prefix. Preserving the slash as a directory separator would allow natural grouping:

worktrees/
  feature/
    add-payments/
    update-dashboard/
  issue/
    fix-login/
    fix-timeout/
  hot-fix/
    critical-patch/

This makes it easier to navigate worktrees when you have many active branches, and it matches the hierarchical structure that git itself uses for refs.

Current behavior

$ awt issue/plugin-routes-not-registered
# Creates: worktrees/issue-plugin-routes-not-registered

Desired behavior

$ awt issue/plugin-routes-not-registered
# Creates: worktrees/issue/plugin-routes-not-registered

Notes

I notice that worktree.branch_name_sanitization_enabled and worktree.branch_name_sanitization_replacements were removed in v0.5.0 with the note "no one ever used these." If restoring and wiring up that config is the right path to solve this, I'd be in favor of that. But however it gets done, the core ask is just: let slashes in branch names become subdirectories in the worktree path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions