How to work in multiple branches of the same repo at the same time
Roberto Tonino

Roberto Tonino @robertotonino

Location:
Udine, Italy
Joined:
Jun 11, 2020

How to work in multiple branches of the same repo at the same time

Publish Date: Jan 28 '22
2 0

You can use Git worktrees 🌲 to achieve so. Just cd in a git repo and run

git worktree add <filesystem-location> <branch>
Enter fullscreen mode Exit fullscreen mode

and git will create a new folder in the path <filesystem-location> and checkout the branch <branch> in that folder.

For instance:

git worktree add ../app-4.2.0 production-4.2.0
Enter fullscreen mode Exit fullscreen mode

Now you can manage 2 copies of the same repo at the same time 💏🏽

Full reference: https://git-scm.com/docs/git-worktree

Comments 0 total

    Add comment