Mastering Jujutsu (jj): A Safer and Smarter Version Control System than Git

Git tutorial - IT technology blog
Git tutorial - IT technology blog

Why I chose Jujutsu over staying strictly loyal to Git

Imagine this scenario: it’s 2 AM, and you’re fixing a critical logic bug. Under pressure, you accidentally type git reset --hard before you’ve had a chance to commit. With Git, four hours of intense coding can vanish instantly if you haven’t git added it to the index. It’s a gut-wrenching feeling.

After that incident, I realized Git can sometimes be too strict and prone to data loss if you make a mistake. I needed a more forgiving tool that allows for errors and easy fixes. That is why I switched to Jujutsu (jj).

Jujutsu is a next-generation version control system (VCS) that runs directly on top of Git. You still use your old repos and push code to GitHub for your colleagues, but your personal workflow experience is significantly smoother. After three months of applying it to my individual workflow within an eight-person team, I’ve spent almost zero time struggling to recover code due to mistyped commands.

Practical improvements that make your life easier

  • Goodbye Staging Area: You no longer need git add. Every change in your working directory is automatically treated as an in-progress commit.
  • Operations Log (Ops Log) System: Every command you type is recorded in a history. Accidentally deleted a branch or performed a wrong rebase? Just run jj op undo. It works like a Ctrl+Z for your entire Git history.
  • Conflicts are no longer blockers: In Git, conflicts force you to stop and resolve them immediately. With Jujutsu, you can commit conflicting files, push them for the team to see, or leave them to be handled later without blocking your workflow.

Install Jujutsu in 1 minute

Written in Rust, Jujutsu’s execution speed is very impressive. You can install it quickly via Cargo or popular package managers depending on your operating system.

# For Rust/Cargo
cargo install --locked --bin jj jujutsu

# macOS (Homebrew)
brew install jj

# Windows (Scoop)
scoop install jj

Verify the installation with the command jj --version. If the terminal returns a version number, you’re ready to say goodbye to hassles like Git’s “detached HEAD.”

Configuration to get started

Unlike the traditional .gitconfig file, Jujutsu uses the modern TOML format. You need to declare your personal information in the config file (usually located at ~/.config/jj/config.toml on Linux/macOS).

[user]
name = "Your Name"
email = "[email protected]"

[ui]
# Choose an editor for writing commit messages
default-editor = "nvim" 

Use side-by-side with existing Git projects

You don’t need to convert your entire project to a new format. Jujutsu can run alongside your current Git directory.

# Change into your Git project directory
jj git init --colocated

The --colocated parameter is extremely useful. It allows you to use git and jj commands interchangeably. Any changes made on the jj side will automatically sync to the hidden .git directory.

Real-world Workflow: Automating every action

When you modify a file like main.py, Jujutsu has already automatically created a “working-copy commit.” You don’t need to type add or commit commands repeatedly to save temporary traces.

# View visual tree diagram
jj log

The screen will display a very clear tree diagram. The current commit is marked with the @ symbol. When you finish a task, just “seal” it:

# Finalize the commit and create a new task
jj commit -m "Fix logic bug found at 2AM"

Conflict Handling: Flexible and Proactive

This is a feature that saves me about 15-20 minutes every time I merge complex branches. Instead of forcing you to fix it immediately, Jujutsu stores the conflict state directly in the commit.

# Merge two conflicting branches
jj merge branch-a branch-b

# Check status
jj status

# You can commit this conflicting file and go grab a coffee, 
# then come back to fix it later without worrying about breaking the repo.

Infinite Recovery with the Operations Log

This is the real “life saver.” Every operation that changes the repo structure, such as rebase, merge, or abandon, is recorded in detail.

# Check recently performed actions
jj op log

The results are displayed transparently:

@  q7w8e9r0 (2023-10-27 02:15:00) commit
│  args: jj commit -m "Update database schema"
◉  a1b2c3d4 (2023-10-27 02:10:00) rebase
│  args: jj rebase -s dev -d main

If you realize that the rebase command at 2:10 AM was a mistake, you only need a single command to go back in time:

jj op undo a1b2c3d4

The entire repo will return to its perfect state before that command was executed. No need to look up complex git reflog entries or worry about losing commit hashes.

Tips for a Professional Workflow

While Jujutsu is very powerful, you should still use jj git push to push code to the remote. Colleagues will receive standard Git commits as usual. They won’t even know you’re using a different tool; they’ll just see that your commit history is always clean and error-free.

If you’re tired of git stash or dread merge conflicts, try installing Jujutsu today. It’s not just a new tool, but a way for you to work with more peace of mind and less pressure.

Share: