Remix.run Logo
oakashes 4 days ago

Something I ran into during exercise 2 (and from watching the solution video[0] closely I see the author did as well):

There were four consecutive changed lines in my original commit. When I split it, I selected the deletion and addition for the first two lines. In the resulting newly created commit, those two lines had been moved to below the other two lines, so the order was now 3 -> 4 -> 1 -> 2, with the second commit moving 3 and 4 back to their original places. I didn't figure out a clean way to fix this - when I edited the commit which changed lines 1 and 2 to put them back at the top, it made a conflict with the second commit which I had to repair.

Anybody know what I should have done differently to split the commit and keep the edited lines in their original places?

[0]: https://www.loom.com/share/e3e148f07fb9420180ebb047f5ca94b3

kinghajj 3 days ago | parent | next [-]

It seems to work correctly if you include the last two lines in the first commit.

    jj-workshop on  HEAD (2cab0f1) [!]
    > jj
    @  unwquwxk samfredrickson@gmail.com 2025-07-29 18:47:18 f7db7c8a
    │  Part 2 first
    ○  wskswvnt samfredrickson@gmail.com 2025-07-29 18:47:13 git_head() 2cab0f16
    │  Part 2 second
    ◆  pnxpmvpz jkoppel@users.noreply.github.com 2025-07-27 21:54:50 main 4d04bcef
    │  Update README.md with link to JJ homepage
    ~
    
    jj-workshop on  HEAD (2cab0f1) [!]
    > jj show w --git
    Commit ID: 2cab0f167c64cea1d23407e12196fa6d1b8aab25
    Change ID: wskswvntlvtwzqutoowyqltsouklzmqr
    Author   : Sam Fredrickson <samfredrickson@gmail.com> (2025-07-29 18:34:52)
    Committer: Sam Fredrickson <samfredrickson@gmail.com> (2025-07-29 18:47:13)
    
        Part 2 second
    
    diff --git a/part1/foo.txt b/part1/foo.txt
    index 067f76475a..56c99c9cc3 100644
    --- a/part1/foo.txt
    +++ b/part1/foo.txt
    @@ -6,5 +6,5 @@
    
     * The best operating system is ______
     * The best text editor is ______
    -* The best kind of phone is _______
    -* The best superhero is ___________
    +* The best kind of phone is nothing
    +* The best superhero is nobody
    
    jj-workshop on  HEAD (2cab0f1) [!]
    > jj show u --git
    Commit ID: f7db7c8a5f37df8c29e08a6697ca6cd59c2313c4
    Change ID: unwquwxklkprlqoksmxzvoumspnmnknk
    Author   : Sam Fredrickson <samfredrickson@gmail.com> (2025-07-29 18:34:52)
    Committer: Sam Fredrickson <samfredrickson@gmail.com> (2025-07-29 18:47:18)
    
        Part 2 first
    
    diff --git a/part1/foo.txt b/part1/foo.txt
    index 56c99c9cc3..f48ae9b3f9 100644
    --- a/part1/foo.txt
    +++ b/part1/foo.txt
    @@ -4,7 +4,7 @@
    
     Maybe fill this out?
    
    -* The best operating system is ______
    -* The best text editor is ______
    +* The best operating system is Linux
    +* The best text editor is neovim
     * The best kind of phone is nothing
     * The best superhero is nobody
3 days ago | parent | prev | next [-]
[deleted]
Darmani 3 days ago | parent | prev [-]

Wow, good catch! I had not noticed. I don't know if there is a fix for this. It seems to be a fundamental issue of the delete-and-add way of representing change hunks.

palata 3 days ago | parent [-]

Is there a way to do something similar to `git add -p`? I am used to editing the patch manually, but jj forces me to use their TUI and I get into the same issue.