Log
Introduction
jj
distinguishes between change and commit. A change is a commit as it
evolves over time. You can consider both to be equivalent only that the change
ID will remain the same as you modify that change (as opposed to the commit ID,
which is different after every amend, rebase etc.). This is very convenient if
you keep modifying the same change. Commits are exactly the same thing as in
Git, in fact jj
relies on having an underlying Git repository.
Another way of looking at it would be to say that the change ID is a label that
jj
attaches to a commit. Whenever you operate on that commit, jj
will
notice this and after modifying the commit will move the label from the old
obsolete commit to the new one. Remember that commits in Git are immutable and
any modification to the parents, commit message, commit date, content etc. will
cause a new commit to be created that will have a different commit ID (hash),
even if the commit may look unchanged at first glance.
The jj log
command shows the history of the repository. If you configured jj
as recommended in the last section, you can simply run jj
to get the log
output.
jj
A few things to note about the above screenshot:
- Starting at the top left,
@
is the working copy, meaning all files as they currently appear in your working directory, including all modifications.jj
always commits everything for you, so@
is a regular Ju Jutsu change (with an underlying commit). If you use Git directly on the repository, all modifications in@
will be displayed as uncommited changes by Git because@
is tracked internally by Ju Jutsu. - Next to it, you have
smmzpnrn
, the change ID. Every change has such an ID that never changes even as you modify, rebase etc. the change. Highlighted is the shortest unique prefix that identifies the change,s
in this case. Whenever a change ID is required you can just use this prefix. - After the email address and commit date you have the commit ID as in Git. It
is in fact exactly the same commit ID as in Git. It will change every time you
modify the change. In this case
cacb68cb
, again with the shortest unique prefixc
highlighted. - The next change
w
has a bookmarkmain
attached to it. Bookmarks are the jj equivalent of branches. Also attached to it is thegit_head()
revset function which identifies the HEAD of the Git repository. You'll notice that the@
change is not included ingit_head()
, meaning it will not appear when for instance you executegit log
. Ju Jutsu maintains a separate internal Git history inside the.jj
directory.
Examples
Try them!
jj -r ::
jj -r ..main -n 3
jj -r kt+
jj -r 'committer_date(after:"2024-12-05") & committer_date(before:"2024-12-06") & ::main'
Check the Revset language for more options.
Other Commands
Try them out!
Some more useful commands and options:
jj -s
jj show
jj show -s main
Takeaways
Key points. As QA because of active recall. Try to come up with the answer yourself before looking 😉
- Questions
- Answers
- What is a change?
- What is
@
?
- A commit as it evolves over time. Even if you amend, rebase or change the description, the change ID will remain the same whereas the commit ID (hash) will not.
- A short expression to refer to the working copy change i.e. the change
that matches all the files in your repository as you are seeing them
right now. It is quite common to refer to the parent or grandparent of
this change with
@-
and@--
respectively.