10 ms·
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 `
by zamalek 1y ago
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.
- AndrewHampton 1y agoIs `jj split` a good option?
- zamalek 1y agoI've tried it, but then I have to remember what has been pushed.
- dylanhu 1y agoI also run into this often, I wonder if there is a simple built-in feature that would allow you to diff against the remote.
- paradox460 1y agoInterdiff
- abound 1y agoThere'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-changed-files-in-the-wrong-commit-how-do-i-move-the-recent-changes-into-another-commit 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
- zamalek 1y agoBut that would undo what I've done, right? I Wang to keep the changes but only diff them against what I've pushed.
- dzaima 1y agoYou 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.
- _bent 1y agoi guess you can run `jj duplicate` before?
- sgjennings 1y agoI 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-changed-files-in-the-wrong-commit-how-do-i-move-the-recent-changes-into-another-commit https://jj-vcs.github.io/jj/prerelease/FAQ/#i-accidentally-c...
- benoitg 1y agoI 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()"
- aseipp 1y agoIf 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.