One struggle I've had when working with worktrees is not a problem with the worktrees themselves but instead how my Intellij manages project configurations. I can't for the life of me get it set up so my configuration can sit relative to multiple worktrees. There's probably a plugin which solves the issue, but at least in my experience the .idea config folder is rooted in its current directory and very difficult to migrate to another folder or worktree. I end up having to re-establish project linting rules, run configurations, what have you, for each new worktree and it becomes too much of a hassle for anything short-lived.
I use git worktrees daily. I'm surprised by how hard it can be to explain them to people who have never used them. Lately I've settled on "like clones, but sharing a .git directory." The article tries to get this across by comparing them to branches, but I think clones are a more intuitive concept to compare against.
To solve some of the ergonomics issues (command verbosity, manual commands to copy over .env files and install dependencies), I wrote autowt, which is a lightweight but powerful worktree manager: https://steveasleep.com/autowt/
Once I dialed in the cli experience, I basically stopped typing 'git checkout <branch>' to change tasks, because it's easier to ignore working directory state when flipping between tasks.
Maybe I'm stubborn, but even in the age of AI, I still use multiple git clones/directories of the same project, e.g.:
~/dev/projectx
~/dev/projectx2
~/dev/projectx3
~/dev/projectx4
very rarely use more than 4–5 per project. Maybe I'm just avoiding wrapping my head around worktrees and actually trying them out.Benefits: These clones act as semi-permanent directories:
- Helps with caching for heavy Docker usage (think of repeated parallel unit, e2e tests)
- I've color-coded my terminal tabs for each clone so I can instantly tell where I am at a glance (kinda like tab groups just with colors)
Maybe if for some reason I need double digits clones of a project I will be more forced to use git worktrees because then it will be annoying to remember in which directory a branch clone lives.
Fossil SCM, conventionally, has been thus way by default.
The one real caveat to this is that if your application has particularly heavy cold starts it can be hard to actually run your worktrees. I usually end up swapping to a regular checkout as each worktree is due for hands-on attention.
This is very interesting and could be very helpful for A/B testing or comparing outputs/speed between 2 branches.
I already know a place I want to use this.
wt is a useful little tool for helping with git worktrees: https://github.com/timvw/wt
I use it's config to copy in some non-repo config and then hooks to start an agent doing analysis.
I do the same thing just checking out the repo multiple times in different directories.
I'm not really sure what worktrees adds on top of that.
[flagged]
What a peculiar title. The title suggest parallel dev without using worktrees, but the article is about using worktrees.
git worktree add -b some-branch ../wts/repo-some-branch origin/main
git worktree list
git worktree remove
All you need