Re: [PATCH 2/2] doc: git-worktree: Add side by side branch checkout example
- From
Michal Suchánek <msuchanek@suse.de>
- Date
- Oct 2, 2025, 18:46 UTC
- Message-ID
- <aN7IcSmHCM-BBLjH@kitsune.suse.cz>
- In-Reply-To
- <dd4027d1-4148-4171-bf17-b5c33881a446@app.fastmail.com>
On Thu, Oct 02, 2025 at 07:51:20PM +0200, Kristoffer Haugsbakk wrote:
Show 13 quoted lines
> On Thu, Oct 2, 2025, at 17:51, Michal Suchanek wrote: > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > > I think this could do with more setup and motivation. > > I’ve seen a lot of questions on worktrees where they introduce the > problem with “I use a bare repository with worktrees”. And I was > puzzled that they kept using bare repositories all the time. I’ve > forgotten some of those details but I do seem to remember that they were > motivated to go all-in on making a ton of worktrees, and using the the > “project root” to do it. > > Is that what the bare-setup is getting at? ;)
It shows one way how to make a ton of worktrees without having them step on each other, hopefully avoiding this pitfall at least in some cases.
Show 28 quoted lines
> > --- > > Documentation/git-worktree.adoc | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/Documentation/git-worktree.adoc b/Documentation/git-worktree.adoc > > index ec31863aec..122b191ff9 100644 > > --- a/Documentation/git-worktree.adoc > > +++ b/Documentation/git-worktree.adoc > > @@ -525,6 +525,16 @@ $ popd > > $ git worktree remove ../temp > > ------------ > > > > +Side by side branch checkouts for a repository using multiple worktrees > > + > > +------------ > > +mkdir some-repository > > +cd some-repository > > +git clone --bare gitforge@someforge.example.com:some-org/some-repository .git > > +git --git-dir=.git worktree add some-branch > > +git --git-dir=.git worktree add another-branch > > +------------ > > This works for me. But why not this? > > git clone --bare <repo> some-repository > cd some-repository > git worktree add some-branch > git worktree add another-branch
I would certainly not recommend that. There is great potential for conflicting with git internal structures of the bare repository.
Thanks
Michal