Skills.MD
# Jujutsu (jj) Version Control Skill
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.
## Core Concepts
### Working Copy as a Commit
Unlike Git, the working copy IS a commit. Changes are automatically snapshotted
when running `jj` commands - no explicit `add` or staging required.
### Change IDs vs Commit IDs
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.
### Revsets
Revsets are expressions to select commits:
- `@` - Working copy commit
- `@-` - Parent of working copy
- `root()` - Repository root
- `bookmarks()` - All bookmarked commits
- `foo..bar` - Commits from foo to bar (exclusive)
- `foo::bar` - Commits from foo to bar (inclusive)
- `A | B` - Union
- `A & B` - Intersection
- `~A` - Complement
### Bookmarks (not Branches)
Bookmarks are named pointers that map to Git branches. They move automatically
when commits are rewritten.
## Quick Reference
| Git Command | Jujutsu Equivalent | Notes |
| --------------------------- | ------------------------- | -------------------------------- |
| `git init` | `jj git init` | Use `--colocate` for Git interop |
| `git clone URL` | `jj git clone URL` | Git repos only |
| `git status` | `jj st` | Shows working copy diff |
| `git diff` | `jj diff` | Diff of working copy |
| `git diff --staged` | N/A | No staging area |
| `git add && git commit` | `jj commit` | Auto-includes all changes |
| `git commit --amend` | `jj squash` | Squash into parent |
| `git log --oneline --graph` | `jj log` | Visual commit graph |
| `git show COMMIT` | `jj show REV` | Show revision details |
| `git checkout -b NAME` | `jj new` | Start new change |
| `git switch BRANCH` | `jj edit BOOKMARK` | Edit existing change |
| `git reset --hard` | `jj abandon` | Discard working copy |
| `git stash` | `jj new` | Just start new change |
| `git rebase B A` | `jj rebase -b A -d B` | Rebase A onto B |
| `git cherry-pick` | `jj duplicate` | Copy commits |
| `git merge` | `jj new A B` | Creates merge commit |
| `git fetch` | `jj git fetch` | Fetch from remote |
| `git push` | `jj git push` | Push bookmarks |
| `git branch NAME` | `jj bookmark create NAME` | Create bookmark |
## Common Workflows
### Starting Work
```bash
# Clone a repo
jj git clone https://github.com/owner/repo
# Or init in existing directory
jj git init --colocate
# Create new change from main
jj new main
# Work on files (no add needed)
# Edit files...
# Describe the change
jj describe -m "feat: add new feature"
# Finish and start next change
jj new
```
### Viewing State
```bash
# Show log with graph
jj log
# Show working copy diff
jj diff
# Show specific revision
jj show @-
# Status of working copy
jj st
# Show file at revision
jj file show path/to/file -r REV
```
### Modifying History
```bash
# Squash working copy into parent
jj squash
# Squash specific change into parent
jj squash -r CHANGE
# Interactive squash (select hunks)
jj squash -i
# Split a commit
jj split
# Edit a commit message
jj describe -r REV -m "new message"
# Edit an older commit
jj edit CHANGE
# Make changes...
jj new # Return to tip
```
### Rebasing
```bash
# Rebase current change onto main
jj rebase -d main
# Rebase branch onto main
jj rebase -b BRANCH -d main
# Rebase revision and descendants
jj rebase -r REV -d DEST
# Rebase source and descendants
jj rebase -s SOURCE -d DEST
```
### Bookmarks and Remotes
```bash
# Create bookmark at current change
jj bookmark create NAME
# Create bookmark at specific revision
jj bookmark create NAME -r REV
# Move bookmark
jj bookmark move NAME -r REV
# List bookmarks
jj bookmark list
# Track remote bookmark
jj bookmark track NAME@origin
# Push bookmark to remote
jj git push --bookmark NAME
# Push all bookmarks
jj git push --all
# Fetch from remote
jj git fetch
```
### Working with GitHub
```bash
# Create PR branch
jj new main
# Work...
jj describe -m "feat: my feature"
jj bookmark create my-feature
jj git push --bookmark my-feature
# Update PR after review
jj edit my-feature
# Make changes...
jj git push --bookmark my-feature
# After merge, clean up
jj git fetch
jj bookmark delete my-feature
```
### Conflict Resolution
Conflicts in Jujutsu don't block rebases - they're recorded in commits.
```bash
# Check for conflicts
jj log # Conflicted commits shown with marker
# Resolve conflicts
jj new CONFLICTED_CHANGE
# Edit conflict markers in files
jj squash # Squash resolution into conflicted change
# Or use resolve command
jj resolve
```
### Undo Operations
```bash
# View operation log
jj op log
# Undo last operation
jj undo
# Restore to specific operation
jj op restore OP_ID
```
## Key Differences from Git
1. **No staging area**: All file changes automatically included
2. **Working copy is a commit**: Always have a "draft" commit
3. **Conflicts don't block**: Rebases complete, conflicts recorded
4. **Change IDs**: Stable references across history rewrites
5. **Operation log**: Full undo capability for any operation
6. **Automatic snapshot**: No risk of losing uncommitted work
## Colocated vs Non-colocated
**Colocated** (`jj git init --colocate`):
- `.git` and `.jj` in same directory
- Can use Git tools alongside jj
- Git sees jj commits
**Non-colocated** (`jj git init`):
- Only `.jj` directory
- Pure jj workflow
- Use `jj git export` to sync to Git
## Additional Resources
### Reference Files
For detailed command reference and advanced workflows:
- **`references/git-command-table.md`** - Complete Git to Jujutsu command
mapping
- **`references/revsets.md`** - Revset syntax and examples
### 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/
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「jujutsu」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次