git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] dir: use per-worktree repository ignore patterns upon request

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 25, 2026, 03:06 UTC
Message-ID
<xmqq7bpvwxfp.fsf@gitster.g>
In-Reply-To
<4a8d1289-2e2b-4fd6-8ada-143992dd7c4d@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 10 quoted lines
> Sharing the same set of exclude patterns between all worktrees seems 
> like a reasonable thing to do - it would be a pain to have to populate 
> them every time a new worktree was created.
>
> 	git rev-parse --git-path info/exclude
>
> always returns the correct path because it uses repo_git_path() which 
> knows whether a particular path is per-worktree or resides under 
> $GIT_COMMON_DIR. It is best to avoid constructing paths manually using 
> "git rev-parse --git-dir"
Great to see the best practice raised, like this.
Show 5 quoted lines
>> Some users may prefer each worktree use its own ignore file; some may
>> prefer both; some may prefer the current behavior.
>
> This sounds quite hypothetical - do we have a concrete use case for 
> per-worktree exclude files?

I can see if somebody wants to have different subset of paths checked out by setting up separate sparse settings. But marking what paths are never be part of the project (which is what exclude is about)? I do not think it is useful in general.

The only case I can think of is a repository that houses more than one completely unrelated histories, perhaps being cheapster on a hosting site that charges per number of repositories or something silly like that.

My https://git.kernel.org/pub/scm/git/git.git/ repository houses two completely unrelated histories, one the project data, and 'todo' that are mostly about tools I personally use to maintain the project. Ideally, the latter branch should have been created and maintained as a separate repository, but back them I didn't have write access outside pub/scm/git/git.git/ (notably pub/scm/git/ itself was not writable to me) and that was the only reason why that unrelated history is pushed into the same repository as a separate and unrelated 'todo' branch. It is not a recommended practice, and if this configuration is primarily to cater to such layout, I do not think we want to add it.

Previous: Phillip WoodNext: D. Ben Knoble
Message 4 of 10 in “dir: use per-worktree repository ignore patterns upon request”
  1. dir: use per-worktree repository ignore patterns upon requestD. Ben Knoble, Apr 24, 2026
  2. brian m. carlsonApr 24, 2026
  3. Phillip WoodApr 24, 2026
  4. Junio C HamanoApr 25, 2026
  5. ignore: note info/exclude lives in GIT_COMMON_DIR, not GIT_DIRD. Ben Knoble, May 8, 2026
  6. brian m. carlsonMay 9, 2026
  7. Phillip WoodMay 11, 2026
  8. D. Ben KnobleMay 11, 2026
  9. ignore: note info/exclude lives in GIT_COMMON_DIR, not GIT_DIRD. Ben Knoble, May 12, 2026
  10. Phillip WoodMay 13, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.