Re: Q: Ignore ./foo, but not script/foo
- From
3Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jul 19, 2018, 08:01 UTC
- Message-ID
- <8736wfd579.fsf@evledraar.gmail.com>
- In-Reply-To
- <5B503FF0020000A10002C6B5@gwsmtp1.uni-regensburg.de>
On Thu, Jul 19 2018, Ulrich Windl wrote:
Show 14 quoted lines
> Hi! > > I have a (simple) question I could not answer elegantly from the gitignore(5) manual page: > > A project produces a "foo" binary in the root directory that I want to ignore (So I put "foo" into .gitignore) > Unfortunately I found out taht I cannot have a "script/foo" added while "foo" is in .gitignore. > So I changed "foo" to "./foo" in .gitignore. I can could add "script/foo", but now "foo" is not ignored any more! > > Is there as solution other than:? > -- > foo > !script/foo > !bla/foo > #etc.
The solution is to just do:
echo /foo >.gitignore
Then it'll ignore the top-level /foo, but nothing else. How did you come up with this "./" syntax? It's not understood by gitignore. From gitignore(5):
A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".