threads / discuss / 23883

gitignore - how to ignore only in current directory

Subject: gitignore - how to ignore only in current directory

## tl;dr

4 messages between May 23, 2010 and May 23, 2010.

replies: 3people: 3as markdown or json

Howard Miller· May 23, 2010, 20:28 UTC · lore

I want to ignore a particular file name in a particular directory. However, the same filename may appear in subdirectories and in those cases I do *not* want it ignored. The documentation seems to imply that git will read up the directories looking for .gitignore files and will ignore files that I need included.

Have I misunderstood this and/or how can this be done. Any enlightenment appreciated!

Bruce Stephens· May 23, 2010, 20:33 UTC · re: Howard Miller · lore

Re: gitignore - how to ignore only in current directory

Howard Miller <howard@e-learndesign.co.uk> writes:
Show 5 quoted lines
> I want to ignore a particular file name in a particular directory.
> However, the same filename may appear in subdirectories and in those
> cases I do *not* want it ignored. The documentation seems to imply
> that git will read up the directories looking for .gitignore files and
> will ignore files that I need included.
Make the pattern begin with /
[...]
Howard Miller· May 23, 2010, 20:38 UTC · re: Bruce Stephens · lore

Re: gitignore - how to ignore only in current directory

Show 7 quoted lines
>> I want to ignore a particular file name in a particular directory.
>> However, the same filename may appear in subdirectories and in those
>> cases I do *not* want it ignored. The documentation seems to imply
>> that git will read up the directories looking for .gitignore files and
>> will ignore files that I need included.
>
> Make the pattern begin with /
Ahh thanks!! Now I know the answer I can see that the docs say that (sort of) :)
Björn Steinbrink· May 23, 2010, 20:36 UTC · re: Howard Miller · lore

Re: gitignore - how to ignore only in current directory

On 2010.05.23 21:28:39 +0100, Howard Miller wrote:
> I want to ignore a particular file name in a particular directory.
> However, the same filename may appear in subdirectories and in those
> cases I do *not* want it ignored.

If the pattern contains a non-trailing slash, then the pattern is matched against the whole path (relative to the directory the .gitignore file is in), not just against the filename relative to its parent directory. So if you want to ignore "foo" only in the directory the .gitignore file is in use "/foo" (without the quotes).

Björn

← back to recent threads