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
Allow relocating worktrees with unstaged changes #3103
wt step relocate currently refuses to relocate worktrees with unstaged changes. This feels like a pointless restriction, given that git worktree move is able to handle them just fine. The whole point of worktrees is that you don't have to commit or stash your changes before switching between them, so I don't see why it should be any different for relocating them. At the very least, there should be a -f/--force option even if you want to encourage committing first just in case.
Thanks for the suggestion. I confirmed locally (git 2.54) that git worktree move happily moves a worktree with both modified-tracked files and untracked files, no --force needed — so the dirty-skip is purely a worktrunk policy, not a git limitation. The check lives in validate_candidates and just calls git status --porcelain to decide whether to skip.
A few considerations for the design that a maintainer will want to weigh in on:
Default vs. opt-in flag. Worktrunk's Data Safety guideline prefers explicit consent for destructive-feeling operations, which would point toward a --force / --allow-dirty flag rather than changing the default. Moving the working copy isn't destructive per se, but it does relocate uncommitted work without a git reflog-style undo path.
Main worktree case is different. Relocating the main worktree can't use git worktree move — the code instead does git checkout <default-branch> on the main worktree and creates a new linked worktree at the expected path (see move_main_worktree). git checkout will refuse to switch branches if it would clobber uncommitted changes, so a --force flag would need to either skip dirty main worktrees with a warning or pass --force through to git checkout (which does lose data — different tradeoff).
A maintainer will pick the right shape here.
In the meantime, the closest existing escape hatch is wt step relocate --commit, which auto-commits dirty worktrees before relocating — not what you're asking for, but it does avoid manual stashing.
A maintainer will take a closer look and prioritize.
Yes — for linked worktrees this is a one-line predicate change in validate_candidates, since git worktree move carries modified-tracked and untracked files along. Posted as #3104.
The main worktree still has to skip when dirty: its relocation falls back to git checkout <default-branch>, which refuses to switch over uncommitted changes. The PR keeps that skip and tightens the warning to (uncommitted changes in main worktree) so the surviving case is clear, with --commit still the escape hatch.
Activity
worktrunk-bot commentedon Jun 17, 2026
Thanks for the suggestion. I confirmed locally (git 2.54) that
git worktree movehappily moves a worktree with both modified-tracked files and untracked files, no--forceneeded — so the dirty-skip is purely a worktrunk policy, not a git limitation. The check lives invalidate_candidatesand just callsgit status --porcelainto decide whether to skip.A few considerations for the design that a maintainer will want to weigh in on:
--force/--allow-dirtyflag rather than changing the default. Moving the working copy isn't destructive per se, but it does relocate uncommitted work without agit reflog-style undo path.git worktree move— the code instead doesgit checkout <default-branch>on the main worktree and creates a new linked worktree at the expected path (seemove_main_worktree).git checkoutwill refuse to switch branches if it would clobber uncommitted changes, so a--forceflag would need to either skip dirty main worktrees with a warning or pass--forcethrough togit checkout(which does lose data — different tradeoff).A maintainer will pick the right shape here.
In the meantime, the closest existing escape hatch is
wt step relocate --commit, which auto-commits dirty worktrees before relocating — not what you're asking for, but it does avoid manual stashing.A maintainer will take a closer look and prioritize.
max-sixty commentedon Jun 17, 2026
that's a great point!
@worktrunk-bot does that mean we can easily enable this, at least for non-main worktrees?
worktrunk-bot commentedon Jun 17, 2026
Yes — for linked worktrees this is a one-line predicate change in
validate_candidates, sincegit worktree movecarries modified-tracked and untracked files along. Posted as #3104.The main worktree still has to skip when dirty: its relocation falls back to
git checkout <default-branch>, which refuses to switch over uncommitted changes. The PR keeps that skip and tightens the warning to(uncommitted changes in main worktree)so the surviving case is clear, with--commitstill the escape hatch.