Interview Prep/Git & GitHub/Git internals: objects, refs and the index

What is the difference between `git worktree` and cloning the repo twice?

AdvancedConceptGit internals: objects, refs and the index
Answer

A worktree is an additional working directory attached to the same .git object store, each with its own HEAD and index. It shares objects and refs, so no extra download or disk for history, and a branch can be checked out in only one worktree at a time. It is ideal for reviewing a PR or running a hotfix without stashing.

git worktree add ../hotfix -b hotfix/1.4 origin/release-1.4
git worktree list
git worktree remove ../hotfix
All Git & GitHub questions Roadmap: Git & GitHub

More on Git internals: objects, refs and the index