Skip to content
R. Matthew Emerson edited this page May 8, 2018 · 1 revision

Worktrees

I often want to have multiple branches from a single repository checked out at the same time. A git feature called worktrees allows this: you can have multiple working directories associated with one git repository.

In the following example, ccl is a directory containing a clone of the ccl repository.

cd ccl
git worktree add -b my-branch ../my-branch-working-dir origin/master
cd ../my-branch-working-dir
# Hack as desired.  When done:
rm -rf my-branch-working-dir
cd ccl
git worktree prune