Defeating Git Rigour Fatigue with Jujutsu

(ikesau.co)

69 points | by ikesau 4 hours ago

15 comments

  • EFLKumo 2 minutes ago
    This remind me of [jj megamerge](https://isaaccorbrey.com/notes/jujutsu-megamerges-for-fun-an...). jj allows concentrating on developing while leaving things for vcs alone, as well as solving vcs things (conflicts) at very beginning (megamerge). Really good.
  • y1n0 2 hours ago
    I don't get why people like jujutsu. I tried it for a while but I work with a quite a few people in the same repo and I need easy named branches that keep up with commits. For all the many problems in git, branches are dead easy. That was the big innovation over svn at the time.

    Last time I tried jj, branches were an extremely laborious process to keep up to date. I don't see how people that aren't working alone can work with that. I have numerous branches in flight at any given time, and my colleagues do as well. The idea of manually keeping them pointed at the right commit is just nuts.

    Maybe they've fixed that astonishing choice since then, and I'd give things another go if they did. But branches and worktrees are how I operate.

    Regarding the article, I have no idea what is going on as I'm red-green color deficient.

    • jolux 1 hour ago
      I assume you mean named branches (bookmarks in jj)? Because anonymous branches in jj are trivial: you just `jj new <parent_change_id>` and you have a new branch.

      Bookmarks aren’t that bad either IMO, especially with the recent addition of `jj bookmark advance`. Curious if you can say more about the particular difficulties you found keeping them up to date?

      • nine_k 51 minutes ago
        Imagine that you use jj, while everyone else who works on the repo along with you uses regular git.

        Is it easy?

        • jolux 40 minutes ago
          Yes, that describes me at both jobs I’ve had since learning jj. Hence why I asked for specifics: I’m genuinely curious what other people struggle with, partially because I’d like to help them if I can, and partially because it gives me a better understanding of common pitfalls which helps when teaching other people.
        • rtpg 6 minutes ago
          yeah nobody "has to know", especially if everyone else is also rebasing etc constantly.
        • jgtrosh 40 minutes ago
          I believe this is the most common scenario, yes. If you're used to actively pushing and pulling from the same branche as your colleagues, you need to learn how to manipulate diverging changes and conflicting bookmarks, but other than that all the jj magic is limited to your local activity.
        • stouset 24 minutes ago
          Yes, that is the case for almost every repo I’ve ever used jj for. It is a complete non-issue. There is virtually zero friction.
        • LoganDark 47 minutes ago
          I use jj all the time for pull requests, in fact I don't use regular git at all anymore, and it's perfectly easy. Not only can I easily keep all my pull requests properly synced to their base branches, but I can easily and very quickly address review comments, keeping the commit stack clean without having to manually squash or amend or anything of that sort. Honestly it's a lot easier and more efficient than git for me because of how much naturally follows rather than requiring explicit imperative fixups.
    • stouset 23 minutes ago
      I’ll be honest, as a long-time jj user, I actually haven’t the foggiest what you’re talking about with branches being laborious to keep up to date. Can you elaborate?
    • LoganDark 52 minutes ago
      I don't try to reimplement the git workflow on top of Jujutsu. I like it because I can let go of a bunch of annoying noise that I needed in Git. I like it because rebases don't have to be synchronous and modal. I like it because I can easily edit history, rearrange the commit graph, change commit descriptions, duplicate, and so much more, and even remotely (without having to checkout first). There's so much to love that I never could've even dreamed of under Git.

      I like Jujutsu so much that I've been working on massive refactors to my tooling in order to support it (example: https://github.com/LoganDark/get-shit-done)

  • winterqt 1 hour ago
    > `absorb` assigns the changes based on whichever previous commit most recently touched those files, which sometimes doesn't actually correspond to which commit should own these particular changes.

    I’m pretty sure `jj absorb` (and its predecessors, `git-absorb` [0] and `hg absorb`) are smarter than this, instead looking at the actual diffs.

    [0]: https://github.com/tummychow/git-absorb

    • ikesau 1 hour ago
      Ah yeah, you're right, that's a misrepresentation on my part - it's based on lines, not the file:

      > [absorb] splits changes in the source revision and moves each change to the closest mutable ancestor where the corresponding lines were modified last. If the destination revision cannot be determined unambiguously, the change will be left in the source revision.

      I use absorb fairly often, fwiw. It's great for when I want to make a patch to a commit that will easily absorb into its right place. And I also, sometimes, prefer the more intentional approach where I decide exactly where each hunk will go.

    • jolux 1 hour ago
      Also `sl absorb`.
  • stouset 17 minutes ago
    This seems like a lot more effort than the (to me) more natural jj workflow of maintaining the idealized series of commits plus a working commit on top. As you make tweaks and fixes you just squash the relevant parts into the already-clean history.

    Basically, if you don’t get into that sort of situation with commits containing parts they shouldn’t in the first place, you don’t need to do any extra work to clean them up. The tip of your branch should be the only “messy” part.

    • 3eb7988a1663 14 minutes ago
      That is a lot of discipline up front. I am sure there are problems which are nicely bucketed, but I usually have to go with the flow and make changes as I see them. I want to keep working with the code, not babysitting version control as I focus on getting the initial version to work.
  • nozzlegear 35 minutes ago
    As a git rebase enjoyer, I've completely switched over to jujutsu. The whole experience is more ergonomic in my opinion, and the default workflow which I use (using `jj new` to create a new change that clearly delineates work on a different "thing" before I start working on it) fits my mental model much better than the traditional write-then-commit workflow we all grew up with.
  • singiamtel 31 minutes ago
    The only thing that stops me from switching to jujutsu is that lazygit already paves through all these paper cuts pretty well, and I'd miss their custom patches feature.

    I see there's a similar project for JJ, but it doesn't seem nearly as polished https://github.com/Cretezy/lazyjj

  • xyzsparetimexyz 36 minutes ago
    With jj I mostly just `jj split -B @`. Nice interactive ui for picking the changes I want into a commit. So many times better than 'git add -p'
  • diath 2 hours ago
    So... git rebase -i?
    • idoubtit 1 hour ago
      No, more like:

          git rebase -i
          # squash all the commits (e.g. in vim with ctrl-v)
          git reset HEAD^
          git add -p
          # interactively pickup the RED hunks
          git ci -m RED
      
      The main difference to jj is that the RED commit is created later with git.
      • nine_k 24 minutes ago
        But isn't the flow nearly identical with jj, because the key part, the moving of hunks, is interactive (aka manual) anyway?
    • nomel 1 hour ago
      Definitely not. Switch to a previous commit, make edits, changes propagate into the future commits (including into a git repo if you wish [1])

      Jj is not git and is not a git tool, it just (thankfully) uses git as a backend, so you can still carry on with the rest of the world.

      [1] https://news.ycombinator.com/item?id=47765759

      • ahepp 1 hour ago
        > Switch to a previous commit, make edits, changes propagate into the future commits

        In what way is that different from using `git rebase -i` to edit a commit?

        • stouset 20 minutes ago
          You can literally jump into a commit and edit its contents directly, and everything is auto-rebased on top.

          There are no modal “sorry rebase failed, best of luck” gotchas. There are no “oops I put the wrong thing in the wrong part of the rebase and now I have to abort and start all over” gotchas.

          It’s rebase, but without all the extra work, mental overhead, failure cases, and effort.

    • 9029 1 hour ago
      I'd recommend reading the post, it's not that long
      • raincole 1 hour ago
        As someone who doesn't know jj and read this article, it does sound like `git rebase -i` to me. I'm sure that if I actually spent time learning jj I'd know the difference though.
    • ai_slop_hater 1 hour ago
      git rebase -i kinda sucks once you tried jj.
  • codemog 1 hour ago
    Or let an agent deal with any git nonsense. Yes I’m already aware some smart alec will lie about the time an agent totally deleted their entire repo and branch.
    • aggregator-ios 1 hour ago
      This is my take on it too. And I built BetterGit (https://www.satishmaha.com/BetterGit/) before agent capabilities became widespread. A lot of things in Git and existing GUIs are just cumbersome, and my app makes it better to handle the most common tasks and makes them easier. It's really meant for newcomers to Git.

      BUT! You can simply ask an agent to commit every meaningful block of work. Or just ask any agent to create a JIRA ticket and start work on that named branch. Or ask it to create work trees and create a PR. Life has gotten much easier without having to fight the command line or confusing GUI UX.

    • pkulak 1 hour ago
      JJ is a whole different way to think about source control. The fact that you don’t need to run an agent just to use it is a nice bonus.
    • nvader 1 hour ago
      You can also have you agent use jj with this skill

      https://github.com/danverbraganza/jujutsu-skill

  • mcookly 1 hour ago
    I'm not an expert in Magit by any means, but I bet there's a way to accomplish this in only a few keystrokes.
  • jonathanyc 2 hours ago
    I have been walking some newer programmers through Git recently, so this topic is fresh on my mind. The commands in the blog post do not look friendlier or even different.
  • mi_lk 1 hour ago
    So: Squash everything together then pick each component out by squash -i to an empty commit.

    Seems straightforward, wouldn’t call it special

    • nomel 1 hour ago
      I think jj will never gain momentum because people only have a git mental model at this point, so won't be able to effectively reason about jj.
      • incognito124 1 hour ago
        I spoke about this before, but jj has the Blub Paradox problem, from the pg's essay Beating the Averages (https://paulgraham.com/avg.html).

        Yes, you can do most commit manipulations with git just like with jj. But, users of jj know they're "looking down the power continuum" (to reuse pg's terminology) when they look at git, whereas git users cannot fathom what's exactly the deal with jj. Unfortunately, the only way to get it is to spend a week with it, with an open mind. It's close to impossible to describe it except "it's really neat" and "wow it removes all git's friction I didn't know existed".

        And, apparently, there's a pattern of having to try at least two times before it becomes intuitive!

        • skydhash 1 hour ago
          > Unfortunately, the only way to get it is to spend a week with it, with an open mind

          We do get it. But have you ever thought that git inflexible nature and full control is what some people people like?

          Having three different state for your work (working tree, staging, and committed) is nice for reviewing code. Picking lines and chunk give me an additional mental state to think about the design of the code.

          And once upon a time, I preferred history log like the one in the article. But this days (mostly inspired by mailing list development style) I wants the commit in my main log to be either features or bug fixes. Everything else is “wip”, which I will squash. It makes it easier when rewriting history, cherry picking, or just browsing the log.

          • jolux 58 minutes ago
            There’s nothing stopping you from using separate changes to emulate the staging area if you want.
            • entrope 37 minutes ago
              That is, in essence, the "squash workflow": https://steveklabnik.github.io/jujutsu-tutorial/real-world-w...

              The big differences are that the jj approach gives you a commit message for the staging change, and lets you jump to some other commit without extra steps.

            • skydhash 35 minutes ago
              I can, but I don’t need to.

              jj has nothing I need, so it would be changes for the sake of changes. I’m not saying it’s bad, but people do need to realize that their struggles are there, not the whole world.

              • jolux 25 minutes ago
                Totally fair :) personally I used to be a git wizard and I am relieved at how much about it I’ve been able to forget since learning jj, but I understand not everyone has the same experience.
  • einpoklum 1 hour ago
    > For large features, I find this workflow far easier than having to maintain strict git rigour for the lifecycle of the feature's development.

    I don't know about all that. All sorts of ex-post-facto automated cut-up-and-splice commits sounds to me like a recipe for an every larger mess. I say maintain git rigor, always. Now, you could say "You only say that because you know git rather than jujutsu" or "if you use git absorb more you'll get it", and theoretically you might be right, but... meh, I kind of doubt it.

  • fragmede 1 hour ago
    The elephant in the room is that I haven't had to do something complicated and manual in git by hand in a long while. I'm using AI to generate code, and further, having it commit to git and pushing and pulling and managing branches and merging for me. So for people new to software development, they can also just ask AI to deal with git, which papers over the harder parts of its UX.