What I am used to in the main worktree land:
on branch main
, I run git pull origin/main
, this fast forwards and pulls all refs down to my local.
My co-worker's branch is newFeature
, so I run git checkout newFeature
and I am on that branch!
How do I do the same when working with a bare repo and git worktrees?
I cannot figure out how to checkout newFeature
locally, such that I have a folder right beside my main
If you need multiple working directories with Git, you can:
clone your bare repository
from within that cloned repo folder, type:
git worktree add -b newFeature ../newFeature origin/newFeature
That will create a newFeature
for that branch, beside your local repo folder.
The OP Saiborg confirms in the comments:
In order for me to do what I wanted, I just had to do this:
git worktree add -b feature/newFeature newFeature origin/feature/newFeature
which worked as expected.