Introduction - Steve's Tutorial on Jujutsu, an alternative front-end to git
Jujutsu is essentially an alternative front-end or "porcelain" to git, both magnificiently simplified and powerful.
I tried it after using Emacs Magit for about six or seven years, and jujutsu is really easier to use than git and useful if one wants a tidy public history of changes (with "tidy" and "public" as Linus Torvalds recommends). Plus it is fully compatible to git as backend - other contributors will not even note you are using it.
like this
paequ2
in reply to HaraldvonBlauzahn • • •Ooooh, that's interesting.
HaraldvonBlauzahn
in reply to paequ2 • • •Another useful property is that while jujutsu does have worktrees, like git, in many cases where one would use git worktrees (for example when writing accompanying documentation ) it is just easier to use another line of changes (what is a branch in git).
Alas, that jujutsu does not store local change sets automatically on a remote git repo (this happens only when you update and push a git branch), means that still-mutable local changes are not automatically transferred to another computer you work on. And unpublished changes are naturally mutable in jujutsu. But you can safely copy a jj repo via rsync, as changes in jj metadata are thread-safe and atomic. The other way is of course to push a work-in-progress ("WIP") git branch which can mutate and is therefore not allowed to be merged by other people.
ugo
in reply to HaraldvonBlauzahn • • •That’s not really how one would use worktrees in git. Worktrees are useful in the case when e.g. you are working on version 0.15 of your software that has many breaking changes to version 0.14 (perhaps even on a build system level) and you need to release a 0.14.1 patch. Worktrees separate directories which means you don’t need to stash or do a wip commit, nor clear you 0.15 build artefacts. Just cd to a different worktree, checkout the 0.14 branch, create and checkout the 0.14.1 branch, clear build artifacts in a different directory from your main development one, and start working.
When done, just cd back and keep working again without switching branches, clearing artifacts, or doing full rebuilds of the in-development 0.15 version.
Plus, git does not store change sets or branches or anything on any remote unless you push them either, so if you’re having that problem just stop pushing things you don’t want to push. You can totally rsync a git repo, just ensure it’s at rest. Otherwise do what you should be doing anyway: set the repo on another machine as a remote of the other repo, so you can
git pull my_private_machine feature/my_private_branch
without needing to push to a central repo.I’m sure jujutsu has many advantages, but it also reads to me like you’re misunderstanding the git model. Which can be a fair critique of git to be fair, but then we would need to talk about what about the git model people have trouble with, why, and how to address those issues, and so far I haven’t seen any kind of research in that direction from jujutsu (not that I’ve been looking particularly hard)
HaraldvonBlauzahn
in reply to ugo • • •One difference between using worktrees and branches in git is that in git you usually have uncommited stuff that's not finished, and worktrees are a way to avoid committing this. And you want to avoid committing early because it is hard to clean-up later. This hesistsnce to commit is not necessary at all in jujutsu - any change to the source files is already captured and will be restored once you go back to that changeset. There are other cases where you use worktrees in git e.g. to isolate a build and an hour-long integration test running it in parallel to your ongoing work, and in thar cases, you'd use workspaces in jujutsu like you'd in git.
Too many commands that do subtly and irreversivly things on the repo, with potentially messed-up interim states, only to do the conceptually much simpler task to edit and manipulate the directed acyclic graph of commits.
In short, jujutsu is a commit graph editor and does the same with perhaps 10% of the complexity of git. The man pages on the git reset, branch and merge commands are already larger than the whole - and detailed!- documentation of jujutsu.
Steve Klabnik explains this much better than I can here in his blog that I posted.
ugo
in reply to HaraldvonBlauzahn • • •It is simply not my experience that cleaning up commits after committing early is difficult in git. Amending a commit is a single
-a
flag away from thegit commit
command. The opposite problem is when you do too much work and want to split it into multiple commit rather than a huge one, in which casegit add -p
is again a single flag away fromgit add
.In general, git’s entire model is to allow you to work first, and do administrative tasks (including tidying up your commit history etc) later.
And almost nothing is truly destructive in git, the vast majority of cases can be fixed by judicious use of
git reflog
.The only cases I’ve ran into where git repos became corrupted were caused by external tools, mainly GUIs that label buttons with git commands that do something different when clicked (like the button labeled
push
actually doinggit push —all
for no good reason, and such things) with users that have no idea how git works that have been trained just by telling them “click this to save your work, click this to get the last version of the code”Sickday likes this.
HaraldvonBlauzahn
in reply to ugo • • •ugo
in reply to HaraldvonBlauzahn • • •atzanteol
in reply to paequ2 • • •Technically true - but it looks like
jj
does a lot of history re-writing which would require a lot of care to be taken when working on a shared codebase.The page on remotes has some cautions in it.
Working with remotes, e.g., GitHub - Steve's Jujutsu Tutorial
steveklabnik.github.ioHaraldvonBlauzahn
in reply to atzanteol • • •jj
by default refuses to change any commits on published branches such as a master branch that has been pushed. The details are configurable.BTW that's why I linked Linus Torvalds mail on when and why to rewrite history - it is good advice.
atzanteol
in reply to HaraldvonBlauzahn • • •Hrm... It looks interesting but it seems too dedicated to crafting "the perfect commit".
I don't want to "evolve a commit" - I want to capture my changes over time. If I decide later that I want to prepare the commit for merging I will.
I hate it because it's different - but even trying to give it a "benefit of the doubt" I really can't see this as better. It's not like it's difficult to create a "tidy" commit with git as is.
And as far as "easier to use goes"... well... Here's how you get a list of anonymous branches
And since they eschew branches with names you get to memorize hash strings instead of branch names that describe the thing you were doing?
I'm unconvinced. Though
jj undo
looks neat (and also crazy dangerous unless you can undo an undo?).HaraldvonBlauzahn
in reply to atzanteol • • •No trouble, you can still name branches if you want. And no, you don't have to type the whole changeset hash, the first one to three letters are usually sufficient.
Also, branch names are not a permanent thing, they disappear after you merged them.
If you want, to can put an empty commit with the description of what you want to do at the top of your changes, and then use "jj split" to move changes to different commits before it.
There are several common work flows which are explained in Klabnik's blog post.
HaraldvonBlauzahn
in reply to atzanteol • • •Yeah you can undo undo and also resurrect undone states.
If the readability of the commit history really does not matter to you - for exsmple, nobody needs to read this code again - it's possible that jj does not give you enough advantage. Everyone works different.