| name | rebase |
| description | Rebase the current jj (Jujutsu) changeset stack onto the latest trunk. This skill should be used when the user wants to "rebase my stack", "update onto main/trunk", or sync a jj stack with upstream. Stops and reports on conflicts rather than auto-resolving. For committing or opening PRs use jj:commit / jj:commit-push-pr instead. |
Rebase Current Stack
Rebase the current changeset stack (from its root through @) onto the latest trunk.
Context expectations
When invoked from /jj:rebase, the latest changes are already fetched and the stack root is already in context. Do not re-fetch. If invoked directly, fetch first:
jj git fetch
Process
-
Identify the stack root:
jj log -r 'roots(::@ ~ ::trunk())'
- Finds the earliest changeset in the current stack that's not on trunk
- If this returns nothing, you're already on trunk — report that and stop
-
Rebase the stack:
jj rebase -s 'roots(::@ ~ ::trunk())' -d trunk()
- Rebases the entire stack onto trunk using the same revset for consistency
-
Show result:
jj log
Handling conflicts
If the rebase reports conflicts:
- Run
jj status --no-pager to see conflicted files
- Report the conflicts to the user
- Do NOT attempt to resolve automatically — let the user decide
Edge cases
Notes
trunk() is jj's built-in revset for the primary branch (respects repo config)
-s rebases the source and all descendants
::@ means "all ancestors of @ including @"; ~ ::trunk() excludes trunk and its ancestors