Remix.run Logo
DanOpcode 17 hours ago

I started to use JJ during the summer, and now I'm hooked. It feels much easier to do things such as reorder, squash and split commits, as well as change commit message.

forgotpwd16 3 hours ago | parent [-]

How easier than `git rebase -i`? Running this command, opens your editor of choice with this text & an extensive help commented out at the bottom:

    pick 5340360 # First commit.
    pick 12ccd8a # Second commit.
    pick a2b6a59 # Fourth commit.
    pick 2a648f2 # Commit #4.
    pick 6bb5d98 # Commit #5.
    pick af1f2fe # Commit #6.
    pick 7e99e85 # Commit #7.
    pick 7567b18 # Commit #8.
    pick c23819d # Commit #9.
    pick 50941da # Commit #10.
You edit it to (due to help don't really have to remember a single command):

    pick 5340360 # First commit.
    pick a2b6a59 # Fourth commit.
    pick 2a648f2 # Commit #4.
    reword 12ccd8a # Second commit.
    edit 6bb5d98 # Commit #5.
    squash 7e99e85 # Commit #7.
    pick af1f2fe # Commit #6.
    squash 7567b18 # Commit #8.
    drop c23819d # Commit #9.
    pick 50941da # Commit #10.
And then after letting you reword 12ccd8a, edit 6bb5d98, write new messages for (post-edit) 6bb5d98&7e99e85, and af1f2fe&7567b18, you get:

    pick 5340360 # First commit.
    pick 2448f03 # Fourth commit.
    pick 9cefee3 # Commit #4.
    pick 1259a52 # Second "Hi" commit.
    pick 2ca48d8 # Commit #5.Commit #7.
    pick 4bf7bcd # Commit #6.Commit #8.
    pick dbbb733 # Commit #10.
And if you messed up anything, you can always undo it by using your `git reflog`. No matter what you did, you can always go back a previous state! Each state is stored as new commit.

    dbbb733 (HEAD -> master) HEAD@{18}: rebase (finish): returning to refs/heads/master
    dbbb733 (HEAD -> master) HEAD@{19}: rebase (pick): Commit #10.
    4bf7bcd HEAD@{20}: rebase (squash): Commit #6.Commit #8.
    cdc47c1 HEAD@{21}: rebase (pick): Commit #6.
    2ca48d8 HEAD@{22}: rebase (squash): Commit #5.Commit #7.
    6a6fccc HEAD@{23}: commit (amend): Commit #5.
    86ca5f8 HEAD@{24}: rebase (edit): Commit #5.
    1259a52 HEAD@{25}: rebase (reword): Second "Hi" commit.
    b33f89c HEAD@{26}: rebase (reword): Second commit.
    9cefee3 HEAD@{27}: rebase (pick): Commit #4.
    2448f03 HEAD@{28}: rebase (pick): Fourth commit.
    5340360 HEAD@{29}: rebase: fast-forward
    d1406ed HEAD@{30}: rebase (start): checkout d1406ed8145dc84695eb622bc6b3fc078e8098df
    50941da HEAD@{31}: commit: Commit #10.
    c23819d HEAD@{32}: commit: Commit #9.
    7567b18 HEAD@{33}: commit: Commit #8.
    7e99e85 HEAD@{34}: commit: Commit #7.
    af1f2fe HEAD@{35}: commit: Commit #6.
    6bb5d98 HEAD@{36}: commit: Commit #5.
    2a648f2 HEAD@{37}: commit: Commit #4.
    a2b6a59 HEAD@{38}: commit: Fourth commit.
    12ccd8a HEAD@{39}: commit: Second commit.
    5340360 HEAD@{40}: commit (initial): First commit.
Feel like git has a reputation for being hard even for things they're not that much.