News for hackers. Stuff that matters.
Re:Jujutsu for Everyone by zamalek on Sunday August 31, 2025 @01:21PM (#45084963)
I'm a through-and-through JJ convert. One papercut I have experienced a few times (though I am getting much better at avoiding) is what to do when I forget to `jj new`. Assuming that I have pushed the current bookmark to the remote, is there any way to recover a new change that is the diff against the remote? I have tried rebasing, but that leads to bookmark ambiguity instead of the solution I'm looking for.
Re:Jujutsu for Everyone by aseipp on Sunday August 31, 2025 @02:54PM (#45085910)
If I understand you correctly, then you can use `jj interdiff --from name-of-branch@remote --to name-of-branch@git` in order to recover the diff between the remote branch commit and your local version of it; you could then turn that invocation into a Git .patch file and reapply it with patch(1). This only works for one commit.

The more general solution you're looking for I guess is some kind of "split based on interdiff" or something like that. I don't believe there's any way to accomplish this in a single stroke, though.

Re:Jujutsu for Everyone by benoitg on Sunday August 31, 2025 @02:34PM (#45085704)
I fixed this by changing the default immutable heads to include all remote bookmarks. This way, you cannot edit them and the new commit is automatically created when you push to the remote branch.

  [revset-aliases]
  "immutable_heads()" = "trunk() | tags() | remote_bookmarks()"
Re:Jujutsu for Everyone by dylanhu on Sunday August 31, 2025 @01:36PM (#45085090)
I also run into this often, I wonder if there is a simple built-in feature that would allow you to diff against the remote.
Re:Jujutsu for Everyone by paradox460 on Sunday August 31, 2025 @11:15PM (#45089118)
Interdiff
Re:Jujutsu for Everyone by abound on Sunday August 31, 2025 @01:52PM (#45085256)
There's a few different ways to fix this, but here's what the official docs suggest: https://jj-vcs.github.io/jj/latest/FAQ/#i-accidentally-chang...

TL;DR - `jj evolog` and then restore changes from the relevant secret commit ID

Re:Jujutsu for Everyone by zamalek on Sunday August 31, 2025 @02:20PM (#45085537)
But that would undo what I've done, right? I Wang to keep the changes but only diff them against what I've pushed.
Re:Jujutsu for Everyone by dzaima on Sunday August 31, 2025 @02:48PM (#45085852)
You can do a `jj new; jj restore --restore-descendants -f commit_id -t @-` with a commit id (not change id!) from the evolog to "inject" a snapshot from the evolog below your current @, leaving the file state at @ (and everywhere else in the log) intact.

Or if you have a commit ID (or otherwise revset; so a "main@origin" or whatever would work) of a specific commit that you want already, can use that instead of course too.

Re:Jujutsu for Everyone by _bent on Sunday August 31, 2025 @03:18PM (#45086170)
i guess you can run `jj duplicate` before?
Re:Jujutsu for Everyone by sgjennings on Sunday August 31, 2025 @04:47PM (#45086931)
I recently updated that FAQ so it preserves the original commit ID. It’s in the prerelease docs now and will move to “latest” with the release this week: https://jj-vcs.github.io/jj/prerelease/FAQ/#i-accidentally-c...
Re:Jujutsu for Everyone by AndrewHampton on Sunday August 31, 2025 @01:24PM (#45084985)
Is `jj split` a good option?
Re:Jujutsu for Everyone by zamalek on Sunday August 31, 2025 @02:20PM (#45085542)
I've tried it, but then I have to remember what has been pushed.