From: Junio C Hamano <gitster@pobox.com>
To: Michal Suchanek <msuchanek@suse.de>
Cc: git@vger.kernel.org, Eric Sunshine <sunshine@sunshineco.com>,
Sergey Organov <sorganov@gmail.com>,
Ben Knoble <ben.knoble@gmail.com>,
Jason Cho <jason11choca@proton.me>,
"Jakub T. Jankiewicz" <jcubic@jcubic.pl>
Subject: Re: [PATCH 2/2] doc: git-worktree: Add side by side branch checkout example
Date: Thu, 02 Oct 2025 11:06:58 -0700 [thread overview]
Message-ID: <xmqqcy75w531.fsf@gitster.g> (raw)
In-Reply-To: <1d5b41562937d83be261d054989b04db6cb94a86.1759420102.git.msuchanek@suse.de> (Michal Suchanek's message of "Thu, 2 Oct 2025 17:51:35 +0200")
Michal Suchanek <msuchanek@suse.de> writes:
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> ---
> 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
> +------------
It is a good example to have a bare clone and get worktrees attached
to it, but I do not think that it is a great idea to call that bare
clone ".git". It makes it confusing if that some-repository/
directory that has a ".git" directory is a non-bare clone with no
working tree files, or if it is a directory that Git has no
knowledge about, that happens to have a single bare repository plus
worktrees. The answer is the latter, but I suspect that Git itself
would probably be confused (i.e. "cd some-repository && git status"
---if you try it, what does it say?).
Naming it after the project may make it more apparent what is going
on when the user goes into that top-level shell directory, perhaps
like this, if we were working with a "bunny" project:
mkdir bunny
cd bunny
git clone --bare gitforge@someforge.example.com:some-org/bunny bunny.git
git --git-dir=bunny.git worktree add some-branch
git --git-dir=bunny.git worktree add another-branch
Then when you "cd bunny && ls", you'd see the bare repository
bunny.git with two checkouts.
Having said all that.
I know some folks like such a layout for some (perhaps ideological)
reason (i.e. no checkout is more special than others, everybody is
equal), but I am not absolutely sure if it works better in a larger
workflow in practice than having a primary worktree that is not a
bare repository. If you do the above with a non-bare repository in
the center, it would look like this:
mkdir bunny-project
cd bunny-project
git clone gitforge@someforge.example.com:some-org/bunny main
cd main
git worktree add ../my-topic-1
git worktree add ../my-topic-2
and have my interaction with the upstream project only from inside
the primary worktree, i.e., "main". Additional worktrees are more
or less ephemeral, and can go away.
> +
> BUGS
> ----
> Multiple checkout in general is still experimental, and the support
next prev parent reply other threads:[~2025-10-02 18:07 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-27 13:28 What is the reason behind not hiding git worktrees from git? Jakub T. Jankiewicz
2025-09-27 16:52 ` Junio C Hamano
2025-09-27 17:55 ` Michal Suchánek
2025-09-27 21:08 ` Jason Cho
2025-09-27 21:26 ` Jason Cho
2025-09-30 10:30 ` Michal Suchánek
2025-09-30 15:47 ` Junio C Hamano
2025-11-19 8:13 ` Michal Suchánek
2025-09-30 10:37 ` Michal Suchánek
2025-10-01 12:16 ` Ben Knoble
2025-10-01 18:54 ` Junio C Hamano
2025-10-01 20:22 ` Sergey Organov
2025-10-01 20:48 ` Junio C Hamano
2025-10-01 21:27 ` Jakub T. Jankiewicz
2025-10-01 22:07 ` Junio C Hamano
2025-10-01 21:29 ` Eric Sunshine
2025-10-01 22:27 ` Junio C Hamano
2025-10-02 8:38 ` Michal Suchánek
2025-10-02 13:33 ` Junio C Hamano
2025-10-02 15:51 ` [PATCH 1/2] doc: git-worktree: Link to examples Michal Suchanek
2025-10-02 17:42 ` Kristoffer Haugsbakk
2025-10-02 17:44 ` Junio C Hamano
2025-10-02 18:55 ` Michal Suchánek
2025-10-05 20:52 ` Jean-Noël AVILA
2025-10-10 17:10 ` Michal Suchánek
2025-10-10 17:04 ` [PATCH v2 " Michal Suchanek
2025-10-11 4:40 ` Eric Sunshine
2025-10-10 17:04 ` [PATCH v2 2/2] doc: git-worktree: Add side by side branch checkout example Michal Suchanek
2025-10-11 5:17 ` Eric Sunshine
2025-10-23 19:40 ` Junio C Hamano
2025-10-24 10:15 ` Michal Suchánek
2025-10-24 16:57 ` Eric Sunshine
2025-11-18 12:01 ` Michal Suchánek
2025-11-19 7:19 ` Eric Sunshine
2026-01-20 20:38 ` Junio C Hamano
2025-10-02 15:51 ` [PATCH " Michal Suchanek
2025-10-02 17:51 ` Kristoffer Haugsbakk
2025-10-02 18:46 ` Michal Suchánek
2025-10-02 18:47 ` Junio C Hamano
2025-10-02 18:06 ` Junio C Hamano [this message]
2025-10-02 18:39 ` Michal Suchánek
2025-11-17 22:36 ` What is the reason behind not hiding git worktrees from git? Johannes Schindelin
2025-11-17 22:57 ` Junio C Hamano
2025-10-02 2:33 ` Ben Knoble
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqcy75w531.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=ben.knoble@gmail.com \
--cc=git@vger.kernel.org \
--cc=jason11choca@proton.me \
--cc=jcubic@jcubic.pl \
--cc=msuchanek@suse.de \
--cc=sorganov@gmail.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.