Skip to content

docs(extending): add aliases for moving in-progress changes - #2084

Closed
worktrunk-bot wants to merge 1 commit into
mainfrom
docs/extending-copy-changes-aliases
Closed

worktrunk-bot wants to merge 1 commit into
mainfrom
docs/extending-copy-changes-aliases

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Summary

Test plan

  • cargo test --test integration test_command_pages_and_skill_files_are_in_sync (auto-syncs skills/worktrunk/reference/extending.md)
  • Tested all three aliases end-to-end against a scratch repo with a mixed staged + unstaged + untracked working tree, sourcing the directive file in the parent shell. Source/destination states match the comments in the doc.

Closes #938

Adds three [aliases] examples to the Extending Worktrunk page that move or
copy uncommitted work into a new worktree, addressing the use case from
issue #938. Each composes wt switch --create with --execute, relying on the
directive-file passthrough landed in #2077.

Closes #938

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR overlaps almost entirely with #2083 (opened ~2 minutes earlier by another concurrent run). Both close #938, both add the same three aliases (move-changes / copy-changes / copy-staged) with byte-identical alias bodies, and both target docs/content/extending.md. They should be consolidated into one — recommend closing this PR in favour of #2083, which has clearer per-alias explanations (a "How they work" bullet list instead of a single trailing paragraph).

Two smaller observations on the content of this PR if it's the one that ends up merged:

  • The ### Common patterns heading collides with the existing ### Common patterns under Hooks (line 83 of the same file). Zola will disambiguate the slugs to #common-patterns-1, but a more specific heading (e.g. ### Carrying changes into a new worktree) avoids the collision and reads better in the TOC.
  • The trailing paragraph mentions --base, but none of the three aliases as written expose a base flag — wt switch --create {{ to }} always branches from HEAD. The reference to --base is dead text from the reader's perspective; either drop it or rewrite to show how to extend the alias with --base.

Comment thread docs/content/extending.md
copy-staged = '''if git diff --cached --quiet; then wt switch --create {{ to }}; else p=$(mktemp) && git diff --cached > "$p" && wt switch --create {{ to }} --execute="git apply --index '$p' && rm '$p'"; fi'''
```

`--index` preserves the staged-vs-unstaged split when popping. The `git diff --quiet HEAD` guard skips the stash dance when the source is already clean, avoiding noise and never touching a pre-existing stash. If `--base` differs from `HEAD`, `git apply` and `git stash pop` may reject hunks that don't match — the same constraint a native flag would face.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --base clause refers to a flag that the aliases as written never expose — wt switch --create {{ to }} always branches from HEAD, so a reader has no scenario in which this caveat applies. Suggest dropping it (or rewriting to show how to thread --base through the alias if that's the intent):

Suggested change
`--index` preserves the staged-vs-unstaged split when popping. The `git diff --quiet HEAD` guard skips the stash dance when the source is already clean, avoiding noise and never touching a pre-existing stash. If `--base` differs from `HEAD`, `git apply` and `git stash pop` may reject hunks that don't match — the same constraint a native flag would face.
`--index` preserves the staged-vs-unstaged split when popping. The `git diff --quiet HEAD` guard skips the stash dance when the source is already clean, avoiding noise and never touching a pre-existing stash.

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Agreed on all three points. Closing this in favour of #2083, which landed ~2 minutes earlier and uses the cleaner per-alias bullet structure. The heading collision and the --base aside don't apply to #2083 (it uses ### Recipe: move or copy in-progress changes to a new worktree and doesn't mention --base), so no follow-up needed there.

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Closing as duplicate of #2083.

@max-sixty
max-sixty deleted the docs/extending-copy-changes-aliases branch June 18, 2026 06:00
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

1 participant