DEV Community

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

Posted on • Updated on • Originally published at tonino.xyz

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

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

Discussion (0)