From: Junio C Hamano <gitster@pobox.com>
To: "Jakub T. Jankiewicz" <jcubic@jcubic.pl>
Cc: git@vger.kernel.org
Subject: Re: What is the reason behind not hiding git worktrees from git?
Date: Sat, 27 Sep 2025 09:52:56 -0700 [thread overview]
Message-ID: <xmqq4isn96s7.fsf@gitster.g> (raw)
In-Reply-To: <20250927152824.3132af88@jcubic> (Jakub T. Jankiewicz's message of "Sat, 27 Sep 2025 15:28:24 +0200")
"Jakub T. Jankiewicz" <jcubic@jcubic.pl> writes:
> Why git work trees are are not automatically ignored by git?
Because there is no reason to ignore them, and ignoring them would
be annoyingly inconvenient. Worktrees are not special and treated
the same way as an ordinary Git working tree with embedded .git
directory.
That is, if you "git clone" somebody else's project into your
current directory, when you are in the working tree of you git
repository, that working tree of the cloned repository would appear
as an untracked content from the point of view of the containing
repository of yours. It is up to you to add it as a subproject, or
leave it as an untracked directory.
If you do not want to see a new worktree as an untracked directory
in another repository, do not do
$ git worktree add base
in the first place. You are creating the new worktree _inside_ an
existing repository's working tree, and it is no surprise that the
new directory appears as an untracked directory.
In other words, if it hurts, don't do it.
Instead, you can create your additional worktree outside the working
tree you are using. For example, I keep a handful of worktrees just
next to my primary working tree, by doing something like
$ git worktree add --detach ../git.maint maint
$ git worktree add --detach ../git.next next
$ git worktree add --detach ../git.seen seen
when I am in my primary working tree. Then I can leave some work in
progress in my primary working tree and then context switch out to
$ cd ../git.next && git reset --hard next
$ do stuff on next
any one of these additional worktrees.
Hope this helps.
next prev parent reply other threads:[~2025-09-27 16:52 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 [this message]
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
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq4isn96s7.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jcubic@jcubic.pl \
/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 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 NNTP newsgroup(s).