logo

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

Posted on:

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

git worktree add <filesystem-location> <branch>

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

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

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