How I Use Git Worktrees
matklad.github.io
matklad.github.io
I've never used worktrees, but one thing I noticed from this post is that it adds an extra FS dir layer. This would break a few workflows at my company, we use relative paths to reference sibling git repos in certain situations (e.g. to run the server in one repo which servers a build sourced from the sibling frontend repo, etc). Knowing which worktree to use in that case wouldn't really work, those scripts using relative paths would need somekind of input/arg for the worktree name.
If I'm doing new development and bug report comes in, I can just open the production project. I don't need to stop what I'm doing in my development branch at all. I don't have to worry about build artifacts or other details that come when you just switch branches in place. I also really dislike stashing.
I don't know why they aren't more popular.
One neat feature I've also shown people is using worktrees to have many sparse checkouts from a big repo/monorepo so they can be used as more sane chunks.
https://lore.kernel.org/git/xmqq5za8hpir.fsf@gitster.c.googl...
The advantage of worktrees is to have only a single .git, instead of cloning it for every purpose, and also needing to update those separately.
Does anybody know what this is? Google won't help.
``` TL;DR: consider using worktrees not as a replacement for branches, but as a means to manage concurrency in your tasks. My level of concurrency is:
main for looking at the pristine code,
work for looking at my code,
review for looking at someone else’s code,
fuzz for my computer to look at my code,
scratch for everything else!
```