Most active commenters

    ←back to thread

    128 points nvader | 25 comments | | HN request time: 0.021s | source | bottom
    1. rafaelmn ◴[] No.46190591[source]
    So how is this different from git worktrees exactly ?
    replies(2): >>46190753 #>>46191208 #
    2. rk06 ◴[] No.46190753[source]
    there is no difference as jj is only a frontend to git.

    author me tions that git cli require multiple steps when there are unstaged changes.

    I don't know if git has one liner cli command for it as i myself use gitextn to create worktrees

    replies(3): >>46190898 #>>46191762 #>>46201886 #
    3. dubi_steinkek ◴[] No.46190898[source]
    > there is no difference as jj is only a frontend to git.

    That's not really true in this case, as the worktree feature from jujutsu is not implemented on top of git worktrees.

    replies(2): >>46191425 #>>46192334 #
    4. weinzierl ◴[] No.46191208[source]
    In git you can have only one worktree per branch. For example, if you have a worktree on main you cannot have another one on main.

    I personally find this annoying. I usually like to keep one pristine and always current working copy of main (and develop if applicable) around for search and other analysis tasks[1]. Worktrees would be ideal and efficient but due to the mentioned restriction I have to either waste space for a separate clone or do some ugly workarounds to keep the worktree on the branch while not keeping it on the branch.

    jujutsu workspace are much nicer in that regard.

    [1] I know there are tons of ways search and analyze in git but over the years I found a pristine working copy to be the most versatile solution.

    replies(6): >>46191261 #>>46191697 #>>46191865 #>>46192204 #>>46194289 #>>46197961 #
    5. htgb ◴[] No.46191261[source]
    That sounds like a nice improvement, just like many other aspects of jj!

    Tools should adapt to us and not the other way around, but if you are stuck with git, there's a slightly different workflow that supports your use case: detached head. Whenever I check out branches that I don't intend on committing to directly, I checkout e.g. origin/main. This can be checked out in many worktrees. I actually find it more ergonomic and did this before using worktrees: there are no extra steps in keeping a local main pointer up to date.

    replies(1): >>46191472 #
    6. Macha ◴[] No.46191425{3}[source]
    This is kind of unfortunate in this case as it breaks some tooling since the extra trees are not collocated with git, like editor inline history/blame or agents that know to look in git history to fix their mistakes
    replies(2): >>46191784 #>>46194292 #
    7. weinzierl ◴[] No.46191472{3}[source]
    The detached head is what I meant with keeping it on the branch while not keeping it on the branch.

    The complication comes from trying to stay current. With a regular worktree I could just pull, but now I have to remember the branch, fetch all and reset hard to the remembered branch.

    8. rafaelmn ◴[] No.46191697[source]
    OK nice to know. Don't find this limiting for my flow but will keep in mind if I decide to give JJ a try.
    9. gcr ◴[] No.46191762[source]
    jj may use git as (one of) its backing stores, and its collocation offers some compatibility at the cost of important tradeoffs, but it isn’t intended to be a git frontend.
    10. gcr ◴[] No.46191784{4}[source]
    isn’t it strictly better to use your editor’s JJ support and ask Claude to use jj?

    (I personally think jj shouldn’t support collocated repositories, but happy to learn what others see in them…)

    replies(2): >>46192400 #>>46194866 #
    11. PurpleRamen ◴[] No.46191865[source]
    > In git you can have only one worktree per branch. For example, if you have a worktree on main you cannot have another one on main.

    You can detach the worktree from the repo, and checkout multiple branches at the same time to different locations. Not sure if this also allows checking out the same branch to multiple locations at the same time. You can also have a swallow clone, so you don't have to waste space for the full repos history. So at the end you still have to waste space for each worktree, but this isn't something jujutsu can avoid either, or can it?

    12. regularfry ◴[] No.46192204[source]
    You probably know this, but for others that don't: local git clones will share storage space with hardlinks for the objects in .git. The wasted space wouldn't be a doubling, it would be the work tree twice plus the (small) non-hardlinked bits under .git. No idea how LFS interacts with this, but it can be worth knowing about this mechanism.

    Also, if you end up relying on it for space reasons, worth knowing that cloning from a file:// url switches the hardlink mechanism off so you end up with a full duplicate again.

    13. rk06 ◴[] No.46192334{3}[source]
    wtf? it can diverge from git?

    wasn't git compatibility it's main pro?

    replies(5): >>46193172 #>>46194310 #>>46194774 #>>46198872 #>>46201894 #
    14. Macha ◴[] No.46192400{5}[source]
    jj support in editors is way behind git support.
    15. SatvikBeri ◴[] No.46193172{4}[source]
    You can still use git worktrees in a colocated repository. jj workspaces are a different, but similar capability that provide some extra features, at the cost of some others.
    16. mpawelski ◴[] No.46194289[source]
    This restriction of git worktrees is annoying but I just learned one simple rule to follow: Never check out the main development branch (main/master/develop/etc) in other worktrees (non "main worktree", using git-worktree nomenclature)). Use other name with "wt-" prefix for it. Like in:

    git worktree add ..\repo -b wt-main --track origin/main

    And to be honest, after being disciplined to always do that, I very rarely get error message saying that the branch I want to check out is already checked out in other worktree. Before that, I regularly had a situation when I checked out main branch on second worktree to see the current state of the repo (because my main worktree had a work in progress stuff) and after some time when I finished work on main branch, I tried to check out main branch on my main worktree and got the error. Because I totally forgot that I checked it out some time ago in the other worktree.

    replies(1): >>46194663 #
    17. steveklabnik ◴[] No.46194292{4}[source]
    The fix for having worktrees be colocated is in progress. Not sure when it’ll be done but it’s coming.
    18. steveklabnik ◴[] No.46194310{4}[source]
    Yes, jj is its own VCS with pluggable backends.

    Google uses it with Piper, their centralized VCS.

    Being compatible and being purely a frontend aren’t the same thing.

    19. et1337 ◴[] No.46194663{3}[source]
    This is a perfect microcosm example of why I like Jujutsu. Useful git tips and tricks like this are just the default behavior in jj.
    20. aseipp ◴[] No.46194774{4}[source]
    To be technical, it's more that it can read and write the on-disk Git format directly, like many other tools can.

    I think the easiest way to conceptualize it is to think of Git and jj as being broken down into three broad "layers": data storage, algorithms, user interface. Jujutsu uses the same data storage format as Git -- but each of them have their own algorithms and user interface built atop that storage.

    21. aseipp ◴[] No.46194866{5}[source]
    I think the biggest benefits of colocation are, in rough approximation of the order I encounter them:

    1) Various read-only editor features, like diff gutters, work as they usually do. Our editor support still just isn't there yet, I'm afraid.

    2) Various automation that tends to rely on things like running `git` -- again, often read-only -- still work. That means you don't have to go and do a bunch of bullshit or write a patch your coworker has to review in order to make your ./run-all-tests.sh scripts work locally, or whatever.

    3) Sometimes you can do some kind of nice things like run `git fetch $SOME_URL` and then `git checkout FETCH_HEAD` and it works and jj handles it fine. But I find this rare; I sometimes use this to checkout GitHub PRs locally though. This could be replaced 99% for me by having a `jj github` command or something.

    The last one is very marginal, admittedly. Claude I haven't had a problem with; it tends to use jj quite easily with a little instruction.

    22. 1718627440 ◴[] No.46197961[source]
    > In git you can have only one worktree per branch.

    Well, that is true, but a branch is nothing more than an automoving label, so I don't see how that is limiting at all. You can have as many branches as you like and you can also just checkout the commit.

    23. xboxnolifes ◴[] No.46198872{4}[source]
    git is the storage layer. JJ's commands do not have to, and never did, match git one-to-one.
    24. antonvs ◴[] No.46201886[source]
    > there is no difference as jj is only a frontend to git.

    It's easy to get this impression because git is so dominant, so most people using jj use it as a frontend to git.

    But jj is a fully self-contained version control system. It always stores all its commits, branches, and other repo metadata in the .jj directory. You can use it standalone like this without ever using git.

    Git integration is optional, and works by importing from or exporting to Git. Internally, jj still manages its own history. Git support is just a bridge.

    25. antonvs ◴[] No.46201894{4}[source]
    No, that's just a practical approach to supporting migration to jj.

    If we want to improve systems, we need to be able to migrate conveniently from older systems to better ones.