How do I create a worktree from an existing remote branch? #11

Closed
opened 2025-12-30 12:46:24 +00:00 by jadudm · 1 comment
Owner

I want to check out a remote branch into a worktree.

I want to check out a remote branch into a worktree.
Author
Owner

TL;DR: you probably wanted git worktree add ../BRANCH BRANCH

But, really, it looks like this is the best option:

git worktree add ../PATH --checkout BRANCH

I don't have a good source on the solution that worked best for me (.e.g. --checkout). However, if all I want to do is to be in main, and then checkout a branch that a coworker/collaborator has created into a new worktree, then the --checkout form is best.

https://stackoverflow.com/a/45491767

> TL;DR: you probably wanted git worktree add ../BRANCH BRANCH But, really, it looks like this is the best option: ``` git worktree add ../PATH --checkout BRANCH ``` I don't have a good source on the solution that worked best for me (.e.g. `--checkout`). However, if all I want to do is to be in `main`, and then checkout a branch that a coworker/collaborator has created into a new worktree, then the `--checkout` form is best. https://stackoverflow.com/a/45491767
jadudm added the git label 2025-12-30 12:49:48 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jadudm/how-to-do-computer-things#11