Move a worktree to a new location

maintenance & cleanup

// what it does

Moves the working directory and rewrites the linking metadata in both directions, so the worktree keeps functioning at its new path. Worktrees can be identified by a unique trailing path component, so git worktree move hotfix ~/work/hotfix works without spelling out the full old path.

// shell

$ git worktree move ../myapp-hotfix ~/work/hotfix
$ git worktree list

// gotcha

The main worktree and any worktree containing submodules can't be moved this way. For the main worktree: move it with mv, then run git worktree repair from inside it to relink everything.

// resources