jujutsu
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseJujutsu (jj) Version Control Skill
Jujutsu (jj) 版本控制技能
This skill enables working with Jujutsu, a Git-compatible version control system
with a fundamentally different model. Jujutsu treats the working copy as a
commit, has no staging area, and uses change IDs for stable references across
rewrites.
本技能支持使用Jujutsu——一款与Git兼容但核心模型截然不同的版本控制系统。Jujutsu将工作副本视为提交,没有暂存区,并使用变更ID(Change ID)在重写操作中保持稳定引用。
Core Concepts
核心概念
Working Copy as a Commit
工作副本即提交
Unlike Git, the working copy IS a commit. Changes are automatically snapshotted
when running commands - no explicit or staging required.
jjadd与Git不同,Jujutsu的工作副本本身就是一个提交。执行命令时会自动快照变更——无需显式执行或暂存操作。
jjaddChange IDs vs Commit IDs
变更ID vs 提交ID
Every commit has two identifiers:
- Change ID: Stable across rewrites (e.g., )
kkmpptxz - Commit ID: Hash-based, changes on rewrite (e.g., )
abc123def
Use change IDs for references that survive rebases.
每个提交都有两个标识符:
- 变更ID(Change ID):在重写操作中保持稳定(例如:)
kkmpptxz - 提交ID(Commit ID):基于哈希值,重写时会变化(例如:)
abc123def
使用变更ID作为能在变基后保留的引用。
Revsets
版本集(Revsets)
Revsets are expressions to select commits:
- - Working copy commit
@ - - Parent of working copy
@- - - Repository root
root() - - All bookmarked commits
bookmarks() - - Commits from foo to bar (exclusive)
foo..bar - - Commits from foo to bar (inclusive)
foo::bar - - Union
A | B - - Intersection
A & B - - Complement
~A
版本集是用于选择提交的表达式:
- - 工作副本提交
@ - - 工作副本的父提交
@- - - 仓库根提交
root() - - 所有带书签的提交
bookmarks() - - 从foo到bar的提交(不包含foo)
foo..bar - - 从foo到bar的提交(包含foo和bar)
foo::bar - - 并集
A | B - - 交集
A & B - - 补集
~A
Bookmarks (not Branches)
书签(Bookmarks,而非分支)
Bookmarks are named pointers that map to Git branches. They move automatically
when commits are rewritten.
书签是命名指针,与Git分支相对应。当提交被重写时,书签会自动移动。
Quick Reference
快速参考
| Git Command | Jujutsu Equivalent | Notes |
|---|---|---|
| | Use |
| | Git repos only |
| | Shows working copy diff |
| | Diff of working copy |
| N/A | No staging area |
| | Auto-includes all changes |
| | Squash into parent |
| | Visual commit graph |
| | Show revision details |
| | Start new change |
| | Edit existing change |
| | Discard working copy |
| | Just start new change |
| | Rebase A onto B |
| | Copy commits |
| | Creates merge commit |
| | Fetch from remote |
| | Push bookmarks |
| | Create bookmark |
| Git 命令 | Jujutsu 等效命令 | 说明 |
|---|---|---|
| | 使用 |
| | 仅支持Git仓库 |
| | 显示工作副本差异 |
| | 工作副本的差异对比 |
| N/A | 无暂存区 |
| | 自动包含所有变更 |
| | 合并到父提交中 |
| | 可视化提交图谱 |
| | 显示版本详情 |
| | 创建新变更 |
| | 编辑现有变更 |
| | 丢弃工作副本 |
| | 直接创建新变更即可 |
| | 将A变基到B上 |
| | 复制提交 |
| | 创建合并提交 |
| | 从远程仓库拉取 |
| | 推送书签 |
| | 创建书签 |
Common Workflows
常见工作流
Starting Work
开始工作
bash
undefinedbash
undefinedClone a repo
克隆仓库
jj git clone https://github.com/owner/repo
jj git clone https://github.com/owner/repo
Or init in existing directory
或在现有目录中初始化
jj git init --colocate
jj git init --colocate
Create new change from main
从main分支创建新变更
jj new main
jj new main
Work on files (no add needed)
处理文件(无需add操作)
Edit files...
编辑文件...
Describe the change
描述变更
jj describe -m "feat: add new feature"
jj describe -m "feat: add new feature"
Finish and start next change
完成当前变更并开始下一个
jj new
undefinedjj new
undefinedViewing State
查看状态
bash
undefinedbash
undefinedShow log with graph
显示带图谱的提交日志
jj log
jj log
Show working copy diff
显示工作副本差异
jj diff
jj diff
Show specific revision
显示特定版本
jj show @-
jj show @-
Status of working copy
工作副本状态
jj st
jj st
Show file at revision
查看指定版本的文件
jj file show path/to/file -r REV
undefinedjj file show path/to/file -r REV
undefinedModifying History
修改历史
bash
undefinedbash
undefinedSquash working copy into parent
将工作副本合并到父提交
jj squash
jj squash
Squash specific change into parent
将特定变更合并到父提交
jj squash -r CHANGE
jj squash -r CHANGE
Interactive squash (select hunks)
交互式合并(选择代码块)
jj squash -i
jj squash -i
Split a commit
拆分提交
jj split
jj split
Edit a commit message
编辑提交信息
jj describe -r REV -m "new message"
jj describe -r REV -m "new message"
Edit an older commit
编辑旧提交
jj edit CHANGE
jj edit CHANGE
Make changes...
进行修改...
jj new # Return to tip
undefinedjj new # 返回最新提交
undefinedRebasing
变基
bash
undefinedbash
undefinedRebase current change onto main
将当前变更变基到main分支
jj rebase -d main
jj rebase -d main
Rebase branch onto main
将分支变基到main分支
jj rebase -b BRANCH -d main
jj rebase -b BRANCH -d main
Rebase revision and descendants
将指定版本及其后代变基
jj rebase -r REV -d DEST
jj rebase -r REV -d DEST
Rebase source and descendants
将源版本及其后代变基
jj rebase -s SOURCE -d DEST
undefinedjj rebase -s SOURCE -d DEST
undefinedBookmarks and Remotes
书签与远程仓库
bash
undefinedbash
undefinedCreate bookmark at current change
在当前变更创建书签
jj bookmark create NAME
jj bookmark create NAME
Create bookmark at specific revision
在指定版本创建书签
jj bookmark create NAME -r REV
jj bookmark create NAME -r REV
Move bookmark
移动书签
jj bookmark move NAME -r REV
jj bookmark move NAME -r REV
List bookmarks
列出所有书签
jj bookmark list
jj bookmark list
Track remote bookmark
跟踪远程书签
jj bookmark track NAME@origin
jj bookmark track NAME@origin
Push bookmark to remote
将书签推送到远程仓库
jj git push --bookmark NAME
jj git push --bookmark NAME
Push all bookmarks
推送所有书签
jj git push --all
jj git push --all
Fetch from remote
从远程仓库拉取
jj git fetch
undefinedjj git fetch
undefinedWorking with GitHub
与GitHub协作
bash
undefinedbash
undefinedCreate PR branch
创建PR分支
jj new main
jj new main
Work...
进行开发...
jj describe -m "feat: my feature"
jj bookmark create my-feature
jj git push --bookmark my-feature
jj describe -m "feat: my feature"
jj bookmark create my-feature
jj git push --bookmark my-feature
Update PR after review
评审后更新PR
jj edit my-feature
jj edit my-feature
Make changes...
进行修改...
jj git push --bookmark my-feature
jj git push --bookmark my-feature
After merge, clean up
合并后清理
jj git fetch
jj bookmark delete my-feature
undefinedjj git fetch
jj bookmark delete my-feature
undefinedConflict Resolution
冲突解决
Conflicts in Jujutsu don't block rebases - they're recorded in commits.
bash
undefinedJujutsu中的冲突不会阻止变基——冲突会被记录在提交中。
bash
undefinedCheck for conflicts
检查冲突
jj log # Conflicted commits shown with marker
jj log # 冲突提交会带有标记显示
Resolve conflicts
解决冲突
jj new CONFLICTED_CHANGE
jj new CONFLICTED_CHANGE
Edit conflict markers in files
编辑文件中的冲突标记
jj squash # Squash resolution into conflicted change
jj squash # 将解决方案合并到冲突提交中
Or use resolve command
或使用resolve命令
jj resolve
undefinedjj resolve
undefinedUndo Operations
撤销操作
bash
undefinedbash
undefinedView operation log
查看操作日志
jj op log
jj op log
Undo last operation
撤销上一次操作
jj undo
jj undo
Restore to specific operation
恢复到指定操作状态
jj op restore OP_ID
undefinedjj op restore OP_ID
undefinedKey Differences from Git
与Git的主要差异
- No staging area: All file changes automatically included
- Working copy is a commit: Always have a "draft" commit
- Conflicts don't block: Rebases complete, conflicts recorded
- Change IDs: Stable references across history rewrites
- Operation log: Full undo capability for any operation
- Automatic snapshot: No risk of losing uncommitted work
- 无暂存区:所有文件变更会自动被包含
- 工作副本即提交:始终存在一个“草稿”提交
- 冲突不阻塞:变基会完成,冲突被记录下来
- 变更ID:在历史重写中保持稳定的引用
- 操作日志:支持对任何操作进行完全撤销
- 自动快照:不会丢失未提交的工作内容
Colocated vs Non-colocated
共存模式(Colocated)与非共存模式
Colocated ():
jj git init --colocate- and
.gitin same directory.jj - Can use Git tools alongside jj
- Git sees jj commits
Non-colocated ():
jj git init- Only directory
.jj - Pure jj workflow
- Use to sync to Git
jj git export
共存模式():
jj git init --colocate- 和
.git目录在同一位置.jj - 可同时使用Git工具和jj
- Git可以识别jj的提交
非共存模式():
jj git init- 仅存在目录
.jj - 纯jj工作流
- 使用同步到Git
jj git export
Additional Resources
额外资源
Reference Files
参考文档
For detailed command reference and advanced workflows:
- - Complete Git to Jujutsu command mapping
references/git-command-table.md - - Revset syntax and examples
references/revsets.md
如需详细命令参考和高级工作流:
- - 完整的Git与Jujutsu命令映射
references/git-command-table.md - - 版本集语法及示例
references/revsets.md
External Documentation
外部文档
- Official docs: https://docs.jj-vcs.dev/latest/
- Tutorial: https://docs.jj-vcs.dev/latest/tutorial/
- GitHub workflow: https://docs.jj-vcs.dev/latest/github/