Hacker News new | ask | show | jobs
by bilkow 14 days ago
I agree with you but I think that's more of a problem of the tutorials / docs out there than of the tool, which feel like they sell not reviewing your changes before committing as a selling point (that I disagree with). It seems like you just want what's usually called the "squash workflow"[0]. You create a new change on top `jj new`, when you want to "stage" changes, you can use move them to the parent commit by using `jj squash -i` to choose them interactively, or `jj squash path/to/file1 path/to/file2` to choose which files you want to move (similar to `git add`).

In practice I usually just use `jj commit -i`, where you just select the files you want to keep there, edit / add the description (commit message) and a new change is created on top for your new working area.

> compiler artefacts, build files

I agree with my sibling those should be .gitignored and if not, yes those those may cause problems with `jj`

> debug harness

I think that works pretty well with `jj` actually. Let's say mid work you're interrupted and needs to check a an commit. `abc` is your current working copy and `def` is the commit you want to checkout. You can leave your harness behind (`jj new def`), do whatever you need there, then come back (`jj edit abc`). You can also bring your harness with you with `jj rebase -s @ -o def`. If it's something you commonly use, you can create a change for it and keep it as a parent, and then use a filter to prevent changes starting with a prefix (let's say local:) from being pushed. That said, there are some rough edges about keeping changes as a parent IMO (like having to set up command aliases or keep having to move it, depending on your workflow).

[0] https://steveklabnik.github.io/jujutsu-tutorial/real-world-w...

2 comments

> Let's say mid work you're interrupted and needs to check a an commit. `abc` is your current working copy and `def` is the commit you want to checkout. You can leave your harness behind (`jj new def`), do whatever you need there, then come back (`jj edit abc`). You can also bring your harness with you with `jj rebase -s @ -o def`.

It was not complicated with git either. If there was some important change that I didn't want to commit yet, I stash it. Same with experiments that contained valuable information. Then I can use stash apply whenever I want. Never had trouble jumping around the git graph.

One key thing is that I find that conflicts are a very good signal for when the intent of the worktree at commit c clashes with the intent of patch p. Especially if you've designed the code to follow the single responsibility principle. I don't want to sweep this under the rug. Instead I want to solve it right away.

A lot of jj advocates need to better highlight their workflows and why they think git was not doing well for them. I think there's too much focus on managing files instead of unit of changes (contained in patches).

Same as the index, the stash is also just a commit. It's not that it's impossible to do any of this in git, it's that it's more orthogonal in jj. Commits, the stash, and the index are three features in git, but a single feature in jj. This also means you can bring all of the tools to use on your psudeo-index and psuedo-stash that you use to work with commits.
My mental model is like this

commits: clean patches that have been integrated somehow (even as a draft version in my local repo)

index: patch in progress (very short lived as I usually add things and commit right after). It's an editing space.

stash: valuable patches in terms of knowledge, but not relevant to any current task

While they look similar, they have different purposes and so interact with different tools.

I code for one purpose (and maybe get distracted for one thing or two) then goes on to clean up the patches and write a proper message. It's not a matter of adding and rejecting hunks. I also do edit them normally. Tooling is not a problem as I spend more time on reading and editing than on tool calls.

Stashing is similar. The patches stored there are individuals, meaning I don't have to worry about dependency when I delete one. I also don't have to worry about location as there's just one stash concept.

You can also find a way to do the same operation in jj, but I want tooling centered around the concept of a patch, not the concept of commits. jj make it awkward to work with patches.

Sure, I agree with all of this. I just think jj supports doing all of this even easier than git does.
> It was not complicated with git either.

> A lot of jj advocates need to better highlight their workflows and why they think git was not doing well for them.

Yes, I agree. Nowadays I use jj but I had the same feel before trying it, and I do think git usually works fine. What does it for me is just that it makes things simpler and there are fewer commands and special cases. I can use the same command I use to stage things and to move some changes from/to any commit (`jj squash -i`, adding `--from` and `--into` as needed). The same command I use to create a new commit is the one I use to merge (`jj new`, a merge is just a commit with more than one parent). It's super easy to change which commit a branch points to (`jj bookmark move`). With a few commands I can do most things and most of the time I just look at the single page CLI reference[0] to figure it out in a few minutes. I still use git when I need one of the (still) unsupported features, which in my case were submodules and LFS.

> If there was some important change that I didn't want to commit yet, I stash it. Same with experiments that contained valuable information. Then I can use stash apply whenever I want. Never had trouble jumping around the git graph.

Stash: for me, I just find it simpler with jj really. My "stash entries" show up in `jj log` just like everything else, and I immediately know in which parent it's based on. I can use the same commands to deal with the stash as I use for every commit, like I said in the previous paragraph, and I do not need to remember at which index the change was on the stash stack. I can also add a description to it if I want. Surely it's possible to do most of these in git, but in jj I already know how to do all of these as it's the same as any other commit.

> One key thing is that I find that conflicts are a very good signal for when [...] I don't want to sweep this under the rug. Instead I want to solve it right away.

Edit: ah, you're talking about the article. I also don't like leaving conflicts open and I do not use the edit workflow (where you edit commits in history directly). I will either: 1. create a new commit on top of the one I want to edit, then squash and immediately fix conflicts, or 2. work on the latest and squash all the way to the commit I want it on, then fix conflicts. TBF I don't think the way the article does it is too different from what you'd do with git, on git conflicts would only show when you do something like a rebase, a merge, maybe an amend. With the edit workflow it shows up when editing the files. At that point on git you're also "ignoring" the conflicts as you haven't merged / rebased yet.

For me the advantage on `jj`'s conflict handling is that I'll create a new commit on top of the conflicted commit, fix the conflicts there, then review while squashing my fixes (or maybe even comparing to the conflicted commit's parent, with `jj diff --from @--`, this way I can see the whole picture of the fix.

if you are mid work and suddenly need to checkout something you checkout in a new worktree so that all your context remains intact. `git worktree` has been in stable since 2015.

i have not used jj, but if you are introducing sqaush/new just you get what the stage does cleanly then you are implictly agreeing with the stage model.

JJ also has worktrees (called workspaces), but some repositories require more setup (like .env, install dirs, etc), and just checking out ends up being simpler and faster.

> i have not used jj, but if you are introducing sqaush/new just you get what the stage does cleanly then you are implictly agreeing with the stage model.

Squash / new also do it cleanly, just like `git add -e` (I'm not sure what you mean with "cleanly", does it mean "as a special concept?"). And you're right, I agree with the stage model (that's most of the point of my comment!), and I personally think it works pretty well on jj.

> you are introducing sqaush/new just you get what the stage does cleanly

I think that's where I disagree with you. Git introduces the staging area (and stash) as separate concepts divorced from the DAG of changes. JJ just has the DAG, and nothing else. I'd say JJ is the cleaner model.