There are a bunch of posts on the internet about using git worktree command. As far as I can tell,
most of them are primarily about using worktrees as a replacement of, or a supplement to git
branches. Instead of switching branches, you just change directories. This is also how I originally
had useed worktrees, but that didn't stick, and I abandoned them. But recently worktrees grew
on me, though my new use-case is unlike branching.
The different worktrees share the same .git state. The article has an example where the author uses one tree for writing code and one for fuzzing it. If they used multiple clones they’d have to push from the writing directory and pull from the fuzzing directory to get new commits to fuzz but with worktrees this state synchronization between different git directories happens automatically.
The different worktrees share the same .git state. The article has an example where the author uses one tree for writing code and one for fuzzing it. If they used multiple clones they’d have to push from the writing directory and pull from the fuzzing directory to get new commits to fuzz but with worktrees this state synchronization between different git directories happens automatically.