Creating, Describing And Abandoning Changes
Important
Where you learn to create, describe, and abandon commits.
@ x
◆ z � empty
Let’s give x a description (a message, in Git terminology) using jj description or jj desc:
jj desc -m "Initial commit"
Working copy (@) now at: xmvkoxku 45467cdf Initial commit
Parent commit (@-) : zzzzzzzz 00000000 (empty) (no description set)
@ x Initial commit
◆ z � empty
Yes, it’s another hidden Git amend: we won’t repeat that anymore.
New Change
How do you create a new commit?
Remember the CRUD table:
| Operation | Command |
|---|---|
| Create | new |
| Read | show |
| Update | edit |
| Delete | abandon |
Sure, it’s jj new.
jj new -m "A license"
@ xp empty A license
○ xm Initial commit
◆ z empty
This creates a new, empty Change with the specified message. The @ means xp is now the Current Change you are editing.
In Jujutsu, it’s idiomatic (though optional) to commit before
coding. You haven’t added a license file yet, so the Change is
empty. We’ll expand on this workflow later.
Descriptions are optional. You can create a descriptionless Change and add a message later with jj desc.
Let’s add the license file:
echo "This software is open source" > LICENSE
Rest assured, on the next jj command, the file is secured in the repository. Ready for the next Change:
jj new -m "A dummy React.js application"
@ o empty A dummy React.js application
○ t A license
○ x Initial commit
◆ z � empty
You get the point. This is a possible workflow, but we’ll soon see more convenient ones, like The Squash Workflow.
Deleting Changes
Warning
How do you delete a Change? Check the table above.
Tip
Of course,
jj abandon.
Withjj abandon -r <CHANGE-ID>you can delete any Change, no matter its position in the history tree.
Warning
Get rid of the Change adding the license.
Tip
jj abandon -r t@ o empty A dummy React.js application ○ x Initial commit ◆ z � emptyCheck the filesystem: the license is gone.
Hint: when there’s no ambiguity, you can use positional arguments, so
jj abandon tworks too.
Notice you manipulated a Change you weren’t currently on. This feature is everywhere in Jujutsu: we cover it in On Not Being There.