Does one git worktree support multiple branches?
Per the documentation, each
git worktree serves one
prod and so on), but it also sound not reasonable to me, that each branch will have its own
worktree as it will creates many folders, and at some point might be confusing.
git worktree can support multiple
branches? for example all the branches which belongs to
feature and then switch between what relevant for the moment? Is it correct approach?
A git repository can support multiple working trees, allowing you to check out more than one branch at a time. With git worktree add a new working tree is associated with the repository. This new working tree is called a "linked working tree" as opposed to the "main working tree" prepared by git-init or git-clone.
If you want to add a new branches to worktree you need to write:
git worktree add <path> <branch_name>
git checkout -B new_branch git checkout main git worktree add ./new_branch new_branch
To remove it:
git worktree remove
And that how does it look:
in tree view
In path parameter you can pass anything. So you can manage your branches as you want for example you can create folder where you will store only branches with bugfixes or futures.
Answered By – Filip Poplewski