Most active commenters
  • zamalek(3)

←back to thread

Jujutsu for everyone

(jj-for-everyone.github.io)
434 points Bogdanp | 12 comments | | HN request time: 0.86s | source | bottom
1. zamalek ◴[] No.45084963[source]
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.
replies(5): >>45084985 #>>45085090 #>>45085256 #>>45085704 #>>45085910 #
2. AndrewHampton ◴[] No.45084985[source]
Is `jj split` a good option?
replies(1): >>45085542 #
3. dylanhu ◴[] No.45085090[source]
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.
replies(1): >>45089118 #
4. abound ◴[] No.45085256[source]
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

replies(2): >>45085537 #>>45086931 #
5. zamalek ◴[] No.45085537[source]
But that would undo what I've done, right? I Wang to keep the changes but only diff them against what I've pushed.
replies(2): >>45085852 #>>45086170 #
6. zamalek ◴[] No.45085542[source]
I've tried it, but then I have to remember what has been pushed.
7. benoitg ◴[] No.45085704[source]
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()"
8. dzaima ◴[] No.45085852{3}[source]
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.

9. aseipp ◴[] No.45085910[source]
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.

10. _bent ◴[] No.45086170{3}[source]
i guess you can run `jj duplicate` before?
11. sgjennings ◴[] No.45086931[source]
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...
12. paradox460 ◴[] No.45089118[source]
Interdiff