Skip to content
The Git Crypt

/static/cripta/en/ossada/worktree/

Menu

GIT-017 · Workshop

git worktree

Two branches of the same repository, each in its own folder.

worktree add hangs a second working tree off the same repository: another folder, another branch, the same object vault and the same references. No re-cloning, no stacking stashes just to change subjects.

The classic scene: you are mid-feature and an urgent ticket lands. Instead of parking everything, worktree add ../hotfix main opens a clean bench next door — the fix ships from there, and the feature never even notices.

$ git worktree add ../stickybit-hotfix hotfix/rodape
Preparing worktree (checking out 'hotfix/rodape')
$ git worktree list
/Users/andrey/Code/stickybit          3bf1f68 [main]
/Users/andrey/Code/stickybit-hotfix   3bf1f68 [hotfix/rodape]
Two benches, a single object vault.