loading...
Cover image for "Git" more than one branch

"Git" more than one branch

kyleparisi profile image Kyle Parisi ・1 min read

At a previous job I had to review my coworkers code and continue developing a feature. For that I used to just checkout a whole new clone of the project in a review/ folder. From there I could safely review the code locally.

Now I'm working on a large rewrite. This time I need to review how the current system operates. Here is an alternative way to do that:

# git worktree add <path> [<branch>]
git worktree add legacy develop

If you cd to legacy, your git commands will be in the context of that branch. A nice pro-tip to keep in your back pocket!

Discussion

pic
Editor guide
Collapse
itsasine profile image
ItsASine (Kayla)

I like worktrees for writing tests for one branch while tests are running in the "main" branch (full suite of integration tests, so about an hour of runtime). But I end up defaulting to just having 1 active branch and using gitlab's MR diff view for reviews.

Collapse
pkristiancz profile image