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
More on Git internals: objects, refs and the index
What are the four object types in Git's object database?BeginnerIs Git a snapshot system or a diff system?BeginnerWhat is the SHA-1 (or SHA-256) hash of an object and how is it computed?BeginnerWhere does Git store objects on disk, and what are loose objects versus packfiles?IntermediateWhat exactly is a branch, and what does creating one cost?IntermediateWhat is HEAD?Beginner