git worktree
let us to work on more than one branch at a time. It provides a new working directory for each branch.
Create a Worktree
To create a worktree base on an existing branch, we do
git worktree add ../folder <branch-name>
To create a new branch and create a new worktree for it, we can do:
git worktree add ../folder -b <branch-name>
List Worktrees
git worktree list
Remove a Worktree
To remove a worktree, first we remove the folder and prune
the worktree: 1
rm -r ../folder
git worktree prune
Then we can remove the branch for that worktree:
git branch -D <branch-name>