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 • Edited on • Originally published at tonino.xyz

1 1

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

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay