You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@bookkeeper.apache.org by Ivan Kelly <iv...@apache.org> on 2018/03/08 10:23:40 UTC
Intro to git worktree
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/
Re: Intro to git worktree
Posted by Enrico Olivelli <eo...@gmail.com>.
2018-03-08 14:47 GMT+01:00 Ivan Kelly <iv...@apache.org>:
> > I didn't know this great feature!
> > Thank you I will try out soon.
> > I guess as maven uses a shared repo in .m2 you should have several maven
> > repos, one for each local work dir but it is only a matter of adding an
> > argument on the command line
> I just share the repo. It's rare that I have such fundamental changes
> across modules that this doesn't work.
>
I forgot that when running mvn test or mvn verify maven uses the
target/classes directory for intra-reactor dependencies so actually the
problem is mitigated
Thank you
Enrico
>
> -Ivan
>
Re: Intro to git worktree
Posted by Ivan Kelly <iv...@apache.org>.
> I didn't know this great feature!
> Thank you I will try out soon.
> I guess as maven uses a shared repo in .m2 you should have several maven
> repos, one for each local work dir but it is only a matter of adding an
> argument on the command line
I just share the repo. It's rare that I have such fundamental changes
across modules that this doesn't work.
-Ivan
Re: Intro to git worktree
Posted by Enrico Olivelli <eo...@gmail.com>.
Il gio 8 mar 2018, 11:23 Ivan Kelly <iv...@apache.org> ha scritto:
> 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.
>
I didn't know this great feature!
Thank you I will try out soon.
I guess as maven uses a shared repo in .m2 you should have several maven
repos, one for each local work dir but it is only a matter of adding an
argument on the command line
>
> Cheers,
> Ivan
>
> [1]
> https://spin.atomicobject.com/2016/06/26/parallelize-development-git-worktrees/
>
--
-- Enrico Olivelli
Re: Intro to git worktree
Posted by Sijie Guo <gu...@gmail.com>.
yes. worktree is what you needed when you have multiple concurrent tasks in
progress. have been using it for long time.
- Sijie
On Thu, Mar 8, 2018 at 2:23 AM, Ivan Kelly <iv...@apache.org> wrote:
> 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/
>
Re: Intro to git worktree
Posted by Pasha Kuznetsov <pk...@salesforce.com>.
Ivan, I wasn't aware of it, looks very interesting, thanks for sharing!
On Thu, Mar 8, 2018 at 2:23 AM Ivan Kelly <iv...@apache.org> wrote:
> 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/
>
--
Pasha Kuznetsov
Principal Software Engineer | Storage Cloud | Salesforce
Mobile: +1 (319) 535-3858 | Linked.in/pasha-kuznetsov
<https://www.linkedin.com/in/pasha-kuznetsov/>
<https://www.linkedin.com/in/pasha-kuznetsov/>
--