←back to thread

128 points nvader | 1 comments | | HN request time: 0.195s | source
Show context
rafaelmn ◴[] No.46190591[source]
So how is this different from git worktrees exactly ?
replies(2): >>46190753 #>>46191208 #
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 #
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 #
1. et1337 ◴[] No.46194663[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.