# gitignore - how to ignore only in current directory

4 messages from 2010-05-23 to 2010-05-23. Participants: Howard Miller, Björn Steinbrink, Bruce Stephens.
Thread: https://gitlist.dev/t/23883

## Howard Miller, 2010-05-23 20:28

Subject: gitignore - how to ignore only in current directory
Message-ID: <AANLkTilGH-Z4IpgosqYPFCl3G2XsKDfAT3pH6vi-wuN8@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTilGH-Z4IpgosqYPFCl3G2XsKDfAT3pH6vi-wuN8%40mail.gmail.com

```
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, 2010-05-23 20:33

Subject: Re: gitignore - how to ignore only in current directory
Message-ID: <808w7a4atz.fsf@tiny.isode.net>
URL: https://gitlist.dev/e/808w7a4atz.fsf%40tiny.isode.net
In-Reply-To: <AANLkTilGH-Z4IpgosqYPFCl3G2XsKDfAT3pH6vi-wuN8@mail.gmail.com>

```
Howard Miller <howard@e-learndesign.co.uk> writes:

> 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 /

[...]

```

## Björn Steinbrink, 2010-05-23 20:36

Subject: Re: gitignore - how to ignore only in current directory
Message-ID: <20100523203651.GA13942@atjola.homenet>
URL: https://gitlist.dev/e/20100523203651.GA13942%40atjola.homenet
In-Reply-To: <AANLkTilGH-Z4IpgosqYPFCl3G2XsKDfAT3pH6vi-wuN8@mail.gmail.com>

```
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

```

## Howard Miller, 2010-05-23 20:38

Subject: Re: gitignore - how to ignore only in current directory
Message-ID: <AANLkTil3gjr8dS7T5DZJOK8m9mQFRtXIy1TsrUkUCtEX@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTil3gjr8dS7T5DZJOK8m9mQFRtXIy1TsrUkUCtEX%40mail.gmail.com
In-Reply-To: <808w7a4atz.fsf@tiny.isode.net>

```
>> 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) :)

```
