Worktrees allow you to check out multiple branches of the same repository in different directories simultaneously. This is perfect for when you need to quickly look at or fix something on another branch without stashing or committing your current work.
Create a new directory and check out a branch into it. #checkout-elsewhere #clone-local
git worktree add $path $branchgit worktree listWhen you are done with a worktree, you can remove it. This deletes the directory and the Git metadata tracking it. #rm-worktree
git worktree remove $worktreeIf you manually delete a worktree directory using rm -rf, Git still thinks it exists. Use prune to clean up the internal metadata. #fix-worktree #clean-worktree
git worktree prune