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

gitignore documentation for info/exclude files and patterns with relative directories

From
DDDan Drake <dan@dandrake.org>
Date
Mar 27, 2026, 11:20 UTC
Message-ID
<Qdk5yVH_yWgKl_bjCjdasusfe3PuzHCZ2rKgKIn2Xx5rcw46jmQDfA6K2vkv3V3XLSy4aqwyUlfVEmF5VlIv3EVEOlZLEnf-paw11tyhZKE=@dandrake.org>
Hello,
In the "pattern format" section of the gitignore manpage, it says:
Show 7 quoted lines
> The slash "/" is used as the directory separator. Separators may occur at the
> beginning, middle or end of the .gitignore search pattern.
>
> If there is a separator at the beginning or middle (or both) of the pattern,
> then the pattern is relative to the directory level of the particular
> .gitignore file itself. Otherwise the pattern may also match at any
> level below the .gitignore level.

For a .git/info/exclude file, the above makes it sound like the pattern will be relative to that .git/info directory, so that you would need to use this kind of p attern to match files starting with 'foo' in the root of the repo:

../../foo*

However, it seems that for patterns in the info/exclude file, the beginning slash anchors the pattern to the root of the repo; the above pattern in that file should be '/foo*'.

The documentation should mention this behavior for info/exclude, as well as the core.excludesFile.

Dan

-- Ceci n'est pas une .signature.

Next: Junio C Hamano
Message 1 of 3 in “gitignore documentation for info/exclude files and patterns with relative directories”
  1. Dan DrakeMar 27, 2026
  2. Junio C HamanoMar 27, 2026
  3. doc: gitignore: clarify pattern base for info/exclude and core.excludesFileShreyansh Paliwal, Mar 28, 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.