Is there a way to create a new commit, get its change id in a machine-readable way, and not switch to it? #10077
|
Something like Not sure if this is a missing feature, if I'm using an old version, or if there's another way to do it. It would be really useful for merging within a larger script, for example. |
Answered by
PhilipMetzger
Aug 28, 2026
Replies: 2 comments 2 replies
|
You can hack around it: $ jj --config templates.commit_summary=change_id --color never new --no-edit
Created new commit nzsnlovownltwxntvmvlvvsmpuvqyotq
# If you only want the change ID, make sure to redirect stderr to stdout.
$ jj ... new --no-edit 2>&1 | grep -o '[k-z]\+$'
zutzttmzlrvmvmmwrryossxqszovnzvk
# If you're not passing `--no-edit`, it's a little tricky:
$ jj --config templates.commit_summary=change_id --color never new
Working copy (@) now at: uoqlkuusqlyskywuttosoovnmpxxtoml
Parent commit (@-) : ttrqtskotmnzvtvpvvwrrosnqzxzmrrs
$ jj ... new 2>&1 | head -n 1 | grep -o '[k-z]\+$'
nnqkqqpyxppmupsuvuzvnmoyptwqvwss
# Or maybe:
$ jj --config 'templates.commit_summary=if(current_working_copy,change_id)' --color never new
Working copy (@) now at: slmvkolvxzusqyuwxolpnkrywrzzmxms
Parent commit (@-) :
# But you'd still need the `head -n 1`, so 🤷There was a question in the Discord some months ago where I answered this, but I can't find it anymore so unfortunately can't link it. The OP there opted to put null bytes ( Btw, this also works for $ jj --config templates.commit_summary=change_id --color never duplicate
Duplicated 51ad3766f1c2 as ruyqwyuvnlnrzpwvyzqmnsowmzquypmm
$ jj --config templates.commit_summary=change_id --color never duplicate tt:: 2>&1 | grep -o '[k-z]\+$'
rkwtvpozmkysyymwzltwuzqvznsmuprs
pwvrtptyulwqqnxkkxwzvtprruxtrzxn
ruumrylzuslyrxtxmuwvqnvwlupnmomu
mllwysutnqvuslommkxkopqrwkpnzoww
owwtyupqvwruwowssznvorqzpxvqwluv |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is not possible as
jj newprovides no templates. This would be something for multi-command aliases, see #3673.