jj ユースケース別チートシート
https://docs.jj-vcs.dev/latest/git-command-table/ が公式の Docs
git 共存: jj git init --colocate
ブランチ確認
git: git branch
jj: jj bookmark list or jj b l
log 確認
git: git log --oneline -10
jj: jj log --limit 10, jj op log --limit 10
main からブランチを切る
git: git switch -c feature/xxxx, git checkout -b feature/xxxx
jj: jj new main
jj にはブランチという概念が厳密にはないはず
作業内容を commit する
git: git add sample.txt git commit -m 'sample'
jj: jj commit -m "sample" or jj describe -m "sample" してから jj new
jj には add がなくすべて自動で add された状態
これを jj st で確認できる
今の状態を remote に push する
git: git push -u origin feature/xxxx
jj:
jj bookmark create feature/xxxx -r @-
jj bookmark track feature/xxxx --remote=origin
jj git push origin --bookmark feature/xxxx
remote の状態が変わったとき(suggestion や update branch、別の人が Push したなど)
git: git pull origin
jj
jj git fetch → bookmark が移動してくれる
jj new {remote から取ってきた ID}
これをやると、remote から取ってきた最新 commit から @ の woking copy が派生する
直前までの作業は、ローカルの別のところから派生している
jj rebase -s {local の ID} -d feature/xxxx でローカルの変更を remote の最新に rebase
conflict が発生したら jj edit {conflict id} で直す
もしくは jj new {conflict id} で作業して直した後に jj squash でもとの ID に変更をまとめる
conflict したログも残したいなら jj commit -m "resolve conflict" とかでやればいい
途中で別の作業を始めたい
git:
git switch main
git switch -c feature/yyyy
jj
jj new main
もとに戻りたい
git:
git stash
git switch -c feature/xxxx
jj:
jj edit {戻りたいID} or jj new feature/xxxx
---
default log が個人的に見づらいのでカスタムした
https://github.com/jj-vcs/jj/blob/main/cli/src/config/templates.toml から派生
code::config.toml
template-aliases
'my_log_oneline(commit)' = '''
if(commit.root(),
format_root_commit(commit),
label(
separate(" ",
if(commit.current_working_copy(), "working_copy"),
if(commit.immutable(), "immutable", "mutable"),
if(commit.conflict(), "conflicted"),
),
separate(" ",
format_short_change_id_with_change_offset(commit),
commit.author().name(),
commit.bookmarks(),
commit.tags(),
commit.working_copies(),
format_short_commit_id(commit.commit_id()),
format_commit_labels(commit),
if(config("ui.show-cryptographic-signatures").as_boolean(),
format_short_cryptographic_signature(commit.signature())
),
if(commit.empty(), label("empty", "(empty)")),
if(commit.description(),
commit.description().first_line(),
label(if(commit.empty(), "empty"), "(no description set)"),
),
) ++ "\n",
)
)
'''
'my_op_log_oneline(op)' = '''
label(if(current_operation, "current_operation"),
coalesce(
if(op.root(), format_root_operation(op)),
separate(" ",
format_short_operation_id(op.id()),
format_user_redacted(op.user()),
op.time().end(),
op.tags(),
op.description().first_line(),
) ++ "\n",
)
)
'''
templates
log = "my_log_oneline(self)"
op_log = "my_op_log_oneline(self)"