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

Re: Bug in .gitignore handling

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 26, 2008, 20:49 UTC
Message-ID
<7vd4phcit1.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<47EAB3AD.5070507@thorn.ws>
Tommy Thorn <tommy-git@thorn.ws> writes:
Show 23 quoted lines
> Linus Torvalds wrote:
>> On Wed, 26 Mar 2008, Tommy Thorn wrote:
> ...
>> Use "/foo" and it should be ok.
>>
>> Basically, a path with a slash in it is considered absolute, but if
>> the slash is at the end it will only match a directory. A slash at
>> the *beginning* will match the root of the git repository, though.
>
> D'oh, of course that works. I double check the documentation and it
> actually isn't obvious that that is allowed, so I propose this patch.
>
> diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
> index e847b3b..941a8a4 100644
> --- a/Documentation/gitignore.txt
> +++ b/Documentation/gitignore.txt
> @@ -57,6 +57,9 @@ Patterns have the following format:
>    included again.  If a negated pattern matches, this will
>    override lower precedence patterns sources.
>
> + - If the pattern begins with a slash '/', the pattern will only
> +   match in the current directory.
> +
Did you fully read the existing description and Linus's resopnse?

The above is just a special case of a pattern that contains a slash '/' (iow, that falls into "Otherwise" rule that follows "If the pattern does not contain a slash '/'").

 
Previous: Tommy Thorn
Message 7 of 7 in “Bug in .gitignore handling”
  1. Tommy ThornMar 26, 2008
  2. Junio C HamanoMar 26, 2008
  3. Tommy ThornMar 26, 2008
  4. Linus TorvaldsMar 26, 2008
  5. Linus TorvaldsMar 26, 2008
  6. Tommy ThornMar 26, 2008
  7. Junio C HamanoMar 26, 2008

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.