Hi folks,

I just wanted to point out the git "worktree" command. I stumbled
across last year even though it's been around for a long, and it's
completely changed how I work with git. I guess others may also be
unaware of it.

Basically it allows you to work on multiple checkouts of the same
repo. Which makes it very cheap to have multiple patches on the go at
once.

Before using it, a common scenario for me was the following. I'd have
a patch up for review, and I would have moved on to working on
something else. Someone would make a comment on the review, and I'd
need to change something. I'd need commit or stash whatever I was
working on, checkout out the branch, make modifications, run the tests
(and not be able to touch the repo while it's running), push, and then
checkout/unstash the previous thing I had been working on and try to
rebuild all the context I had lost in my head.

With worktree this isn't an issue. Before I create a PR, I usually
create a worktree in a directory called checkouts.

git worktree add checkouts/some-pr-branch some-pr-branch

Then if there are comments, I just open the file in that tree, modify
it, kick off tests, and go back to what I was working on.

Anyhow, I thought this could be useful for folks who haven't come
across the feature yet. As I said, it's revolutionized how I work with
branches.

[1] has further info. And there's the manpage obviously.

Cheers,
Ivan

[1] 
https://spin.atomicobject.com/2016/06/26/parallelize-development-git-worktrees/

Reply via email to