AgentSkillsCN

jujutsu

借助 Jujutsu(jj)进行版本控制管理,包括变基操作、冲突解决,以及与 Git 的互操作。适用于追踪变更、浏览历史、压缩/拆分提交,或向 Git 远程仓库推送代码的场景。

SKILL.md
--- frontmatter
name: jujutsu
description: Manages version control with Jujutsu (jj), including rebasing, conflict resolution, and Git interop. Use when tracking changes, navigating history, squashing/splitting commits, or pushing to Git remotes.

Jujutsu

Git-compatible VCS focused on concurrent development and ease of use.

Key Commands

CommandDescription
jj stShow working copy status
jj logShow change log
jj diffShow changes in working copy
jj newCreate new change
jj descEdit change description
jj squashMove changes to parent
jj splitSplit current change
jj rebase -s src -d destRebase changes
jj absorbMove changes into stack of mutable revisions
jj bisectFind bad revision by bisection
jj fixUpdate files with formatting fixes
jj signCryptographically sign a revision
jj metaeditModify metadata without changing content

Project Setup

bash
jj git init              # Init in existing git repo
jj git init --colocate   # Side-by-side with git

Basic Workflow

bash
jj new                   # Create new change
jj desc -m "feat: add feature"  # Set description
jj log                   # View history
jj edit change-id        # Switch to change
jj new --before @        # Time travel (create before current)
jj edit @-               # Go to parent

Time Travel

bash
jj edit change-id        # Switch to specific change
jj next --edit           # Next child change
jj edit @-               # Parent change
jj new --before @ -m msg # Insert before current

Merging & Rebasing

bash
jj new x yz -m msg       # Merge changes
jj rebase -s src -d dest # Rebase source onto dest
jj abandon              # Delete current change

Conflicts

bash
jj resolve              # Interactive conflict resolution
# Edit files, then continue

Templates & Revsets

bash
jj log -T 'commit_id ++ "\n" ++ description'
jj log -r 'heads(all())'    # All heads
jj log -r 'remote_bookmarks()..'  # Not on remote
jj log -r 'author(name)'    # By author

Git Interop

bash
jj bookmark create main -r @  # Create bookmark
jj git push --bookmark main   # Push bookmark
jj git fetch                 # Fetch from remote
jj bookmark track main@origin # Track remote

Advanced Commands

bash
jj absorb               # Auto-move changes to relevant commits in stack
jj bisect start         # Start bisection
jj bisect good          # Mark current as good
jj bisect bad           # Mark current as bad
jj fix                  # Run configured formatters on files
jj sign -r @            # Sign current revision
jj metaedit -r @ -m "new message"  # Edit metadata only

Tips

  • No staging: changes are immediate
  • Use conventional commits: type(scope): desc
  • jj undo to revert operations
  • jj op log to see operation history
  • Bookmarks are like branches
  • jj absorb is powerful for fixing up commits in a stack

Related Skills

  • gh: GitHub CLI for PRs and issues
  • review: Code review before committing