From: Eric Sunshine <sunshine@sunshineco.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Sergey Organov" <sorganov@gmail.com>,
"Ben Knoble" <ben.knoble@gmail.com>,
"Michal Suchánek" <msuchanek@suse.de>,
"Jason Cho" <jason11choca@proton.me>,
"Jakub T. Jankiewicz" <jcubic@jcubic.pl>,
git@vger.kernel.org
Subject: Re: What is the reason behind not hiding git worktrees from git?
Date: Wed, 1 Oct 2025 17:29:29 -0400 [thread overview]
Message-ID: <CAPig+cQgZijWi8VV1_QScKPhm9cqhQVvow4N-VH00R4oO1m2xA@mail.gmail.com> (raw)
In-Reply-To: <xmqqa52a1h6x.fsf@gitster.g>
On Wed, Oct 1, 2025 at 4:49 PM Junio C Hamano <gitster@pobox.com> wrote:
> Sergey Organov <sorganov@gmail.com> writes:
> > Also, I'm almost sure that the first thing almost every worktree novice
> > does (I did), quite naturally, is:
> >
> > $ git wotktree add <branch>
> >
> > that happily succeeds /anywhere/ inside primary worktree without any
> > warning for me. It probably should either have created $top/../<branch>
> > instead, or refuse to proceed without confirmation in the first place.
>
> Yeah, I almost never type 'git worktree add <directory>' without
> "../" at the beginning of the directory, and every time I do so, I
> do wonder if this is a UI pitfall that we should warn the users
> about. Perhaps we should start from documentation updates and
> possibly a new warning or two?
Every example in the git-worktree documentation which mentions a
literal path (as opposed to generic <path>) already uses the "../"
prefix (and has from inception), including the example in the
introductory paragraphs:
For instance, `git worktree add ../hotfix` creates new branch hotfix
and checks it out at path `../hotfix`.
and the "real" Example block toward the end of the man page:
$ git worktree add -b emergency-fix ../temp master
$ pushd ../temp
# ... hack hack hack ...
$ git commit -a -m 'emergency fix for boss'
$ popd
$ git worktree remove ../temp
There are exactly zero examples in the man page lacking the "../" prefix.
It would be possible, of course, to add a "best practices" section to
the introductory paragraphs advising against creating worktrees as
subdirectories of the "main" worktree (assuming people even agree that
a best practice is to place worktrees elsewhere). However, considering
that the existing examples using "../" have been ignored (in a
fashion), one wonders how much a "best practices" discussion would
help (assuming people aren't really reading the documentation anyhow,
and may very well be cargo-culting git-worktree commands from blogs or
external tutorials).
Regarding issuing warnings: I'm not fond of the idea. There are plenty
of people who already locate worktrees as subdirectories of the main
worktree[*] and do so without problem, and for whom it is a preferred
workflow, so I don't see why we would want to penalize them by warning
against doing so, especially since there is no technical reason to
avoid the practice (i.e. Git handles it just fine). The only minor
downside of the practice (if one considers it a downside) is an
aesthetic one: having to update ".gitignore" or ".git/info/exclude",
or to simply consider them "visual noise" in git-status output and
skip over them when scanning the output. Moreover, I think this is the
first time that we have (on the list, at least) heard a complaint
about the "noise", which may suggest that this is a non-issue for most
people, and that a warning telling people to avoid the practice would
be unwelcome.
Aside: It might be valuable to extend the documentation to add a
discussion about hanging worktrees off of a bare repository. People do
use such a workflow, and git-worktree officially supports it, but I
don't think there is any in-project documentation which mentions it.
FOOTNOTES
[*]: There have been numerous emails on the list showing that placing
worktrees as subdirectories of the main worktree is common enough
practice. And, as far as "experienced users" are concerned (not just
novices picking up the practice from blogs or tutorials), I recall an
email discussion in which Dscho has said that he locates worktrees as
subdirectories of the main worktree, as well. I, too, have done so on
occasion.
next prev parent reply other threads:[~2025-10-01 21:32 UTC|newest]
Thread overview: 43+ 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 [this message]
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
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
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPig+cQgZijWi8VV1_QScKPhm9cqhQVvow4N-VH00R4oO1m2xA@mail.gmail.com \
--to=sunshine@sunshineco.com \
--cc=ben.knoble@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jason11choca@proton.me \
--cc=jcubic@jcubic.pl \
--cc=msuchanek@suse.de \
--cc=sorganov@gmail.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).