Worktree UX #2803
Replies: 11 comments 11 replies
-
Is that much different to cloning the repo a few times? |
Beta Was this translation helpful? Give feedback.
-
I don't currently use work trees very often... But if it was easier to create worktrees within LG I would use them a lot. I'd mostly use them for PRs. |
Beta Was this translation helpful? Give feedback.
-
I use worktrees all the time and I am using bare repositories. This is essential to my development to be able to switch between branches without commit, stash or unstash files. I have 2 cases :
My folder structure is :
In my case the branch name is close to the worktree (I cut the worktree name to have simpler names) |
Beta Was this translation helpful? Give feedback.
-
I don't understand the point of bare repos. I started with them but quickly went to a normal clone. I have a tab in my terminal per worktree/per branch. The first tab is the original clone of our monorepo that I tend to leave alone and not work inside (I may read code in it when I'm asked questions). So to create a new worktree/branch I switch to that first tab and run
Which creates a new directory next to the original clone directory with a worktree/branch using the name I provided.
Thanks to git aliases I'm not sure there is much lazygit can do to improve my workflow; apart from maybe merging the deletion of a worktree and its branch into one operation. At the moment I run:
followed by
to prune merged branches. But sure I could run the two together myself in a git alias...I'll probably update that now that I think about it. Having to start lazygit to manage worktrees seems unnecessary given how few characters it requires to do it via the CLI which I have open all the time. That's, of course, with my workflow, others may disagree. |
Beta Was this translation helpful? Give feedback.
-
Thank you for adding git worktree support! Regarding the UX, do you think we could/should |
Beta Was this translation helpful? Give feedback.
-
Hi @jesseduffield, I am totally loving the lazygit experience so far. Had a couple queries regarding worktrees:
|
Beta Was this translation helpful? Give feedback.
-
Hello - I currently use worktrees like this:
Giving me a project structure like:
lazygit does not seem to be able to recognize other existing worktrees like this, or allow me to launch it from inside Perhaps this is something that can be supported when using worktrees? |
Beta Was this translation helpful? Give feedback.
-
I don't see this mentioned but I would really love to hear others feedback and how they approach this. Basically worktrees ignore the How do you guys handle this now, would this be useful? |
Beta Was this translation helpful? Give feedback.
-
I use worktrees similarily to others: bare repo + worktree per branch. All of this integrated with nvim/telescope. You might find this video informative https://www.youtube.com/watch?v=IK_mjDqGUYE |
Beta Was this translation helpful? Give feedback.
-
I'm fairly new to using worktrees but the workflow that I've found makes sense to me (worktree for each branch) is to create a folder for the repo, then clone the main branch into a directory named However, one "bug" I've encountered is that setting a remote branch as the ref for a new worktree (i.e. leave blank to check out I'm not sure if this is intended, but to me it seems like it should create a new local branch with the name matching the remote, similar to when checking out a remote branch in branch pane 3. mkdir repo
cd repo
git clone [email protected]:my/repo.git main
cd main
lazygit
### Inside Lazygit
# Create new worktree
# If a remote branch is selected as the ref
# and prompt is left blank to check out remote
# switch into new worktree and check out the remote I also set I prefer this to creating bare repos as a lot of IDEs and other git UIs don't support bare repos very well. |
Beta Was this translation helpful? Give feedback.
-
A feature that I would like to see is to is to have some setting where the name and path follows a pattern. I'm pretty much always cloning into a |
Beta Was this translation helpful? Give feedback.
-
We're adding worktree support in the next release. I want to know, how do you use worktrees?
NOTE: worktree support is now on the master branch so feel free to try it out and give feedback.
Here's the draft PR for worktrees if you want to try it out and give feedback: #2147
Reading online I've seen a couple ways that people use git worktrees. One is to create one worktree per branch, where the worktree path is based on the branch name. Another is to have a limited set of worktrees that are re-used (not sure how much of that comes down to personal preference vs it being expensive for those with huge repos to spin up new worktrees on the fly).
There is also the matter of where to put the worktrees. Some people have a
.worktrees
directory within their repo which is either ignored/excluded by git, and some people opt to store worktrees in outside the repo. Some people create a bare repo so that there's no distinction between main and linked worktrees, though it's not clear to me what the pros/cons of that are.I want to know all these things because it'll influence the worktree UX. For example:
66 votes ·
Beta Was this translation helpful? Give feedback.
All reactions