Files
gh-edmundmiller-dotfiles-co…/commands/squash.md
2025-11-29 18:24:50 +08:00

2.0 KiB

allowed-tools, argument-hint, description, model
allowed-tools argument-hint description model
Bash(jj log:*), Bash(jj diff:*), Bash(jj status:*), Bash(jj squash:*)
revision
Merge commits in the stack claude-haiku-4-5

Context

  • Current status: !jj status
  • Current commit: !jj log -r @ --no-graph -T 'concat(change_id.short(), ": ", description)'
  • Parent commit: !jj log -r @- --no-graph -T 'concat(change_id.short(), ": ", description)'
  • Recent stack: !jj log -r 'ancestors(@, 5)' -T 'concat(change_id.short(), ": ", description)' --no-graph

Your Task

Merge commits in the jujutsu stack.

Usage Modes:

  1. Default (no argument): Merge current commit (@) into its parent (@-)

    jj squash
    

    This moves all changes from @ into @-, then abandons @.

  2. With revision: Merge a specific revision into its parent

    jj squash -r <revision>
    

    Useful for cleaning up a specific commit in the stack.

When to use:

  • Multiple WIP commits for the same feature
  • Cleaning up incremental work before sharing
  • Combining related changes into a single commit
  • Fixing typos or small changes that belong in the parent

Workflow:

  1. Explain what will be merged (which commits, what changes)
  2. Execute the squash operation
  3. Show the result with jj log and confirm the changes

Important:

  • Squashing is safe - you can undo with jj undo
  • Use jj squash -i for interactive mode to select specific changes
  • Consider if you should update the description after squashing

Example scenarios:

Scenario 1: Merge current WIP into parent

# Before: @ = "WIP: fix tests", @- = "Add login feature"
jj squash
# After: @ = "Add login feature" (now includes test fixes)

Scenario 2: Merge specific revision

# Merge revision abc123 into its parent
jj squash -r abc123

Scenario 3: Interactive squash

# Choose which changes to move
jj squash -i

Show result: !jj log -r 'ancestors(@, 3)' -T 'concat(change_id.short(), ": ", description)' --no-graph