Skip to content

docs(extending): add recipe for carrying changes to a new worktree - #2083

Merged
max-sixty merged 1 commit into
mainfrom
docs/extending-alias-recipes
Apr 11, 2026
Merged

max-sixty merged 1 commit into
mainfrom
docs/extending-alias-recipes

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Summary

Adds a tested recipe to the Aliases section of docs/content/extending.md showing three [aliases] entries that compose wt switch --create with git's stash/diff plumbing to carry in-progress changes into a new worktree:

  • move-changes — stashes staged + unstaged + untracked, creates the new worktree, and pops the stash with --execute. Source becomes clean.
  • copy-changes — same push, plus git stash apply --index --quiet to restore the source before the new worktree pops. Both sides end up with identical state.
  • copy-staged — writes git diff --cached to a tempfile and applies it with git apply --index in the new worktree, so the source is untouched and staged/unstaged overlap is handled.

Each alias takes the target branch via --var to=feature-xyz. Because an inner wt switch --create inside an alias body propagates its cd to the parent shell (#2077), they drop you in the new worktree directly.

The content was worked out and tested end-to-end in the issue thread (git status --porcelain verified on both sides for clean / staged+unstaged+untracked / untracked-only / empty-staged scenarios).

Closes #938.

Test plan

  • cargo test --test integration test_command_pages_and_skill_files_are_in_sync — keep skills/worktrunk/reference/extending.md in sync
  • pre-commit run --all-files — lints
  • Visual check of the rendered Aliases section on the docs dev server

Three tested aliases (`move-changes`, `copy-changes`, `copy-staged`)
that compose `wt switch --create` with git's stash and diff plumbing
so staged, unstaged, and untracked changes can follow you into a new
worktree. Closes #938.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@max-sixty
max-sixty merged commit 61b0e5a into main Apr 11, 2026
22 checks passed
@max-sixty
max-sixty deleted the docs/extending-alias-recipes branch April 11, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worktree friction: copy staged and unstaged changes when creating new worktree

2 participants