58
Worktrees: Git's best kept secret (and why you should use them)
(www.tomups.com)
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Resources
Rules
Git Logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.
I never really understood the advantage of worktree over having just several clone of the repos on different folders.
Can someone explain me ? I should have missed smth.
Worktrees share the data stored in the
.gitfolder. This saves storage (particularly on larger repos, and if you don't fetch/clone only partial history), and could allow some other workflows or safeguards (backing up just one instead of multiple, centralized local state instead of spread across different workspaces). It also means it could share repo-local git settings - like remotes, local not checked-in ignores, etc. (I assume).It also lets you checkout, cherry-pick, rebase or merge work on other branches without needing to sync between the local clones.