3

I have a large code base (say, a wordpress installation) and want to ignore everything except the few files I myself changed (say, a theme). I know I can ignore files except some single files with

/foo/*
!/foo/bar

But if the directory I want to keep is deeply nested, this does not work. I tried:

/foo/*
!/foo/bar/baz

but baz is ignored as well. There is a proposed solution in a different question that works like

/foo/*
!/foo/bar
/foo/bar/*
!/foo/bar/baz

but this grows to a damn PITA if the directory I want to keep is nested deeper.

Is there a simpler solution to keep /foo/bar/baz but ignore everything else?

Community
  • 1
  • 1
Dominik Schreiber
  • 2,629
  • 1
  • 23
  • 33

1 Answers1

-1
**
!/foo/bar/baz/**

Ignoring everything, except baz and subfolders.

Mattias
  • 1,110
  • 1
  • 11
  • 26
  • i thought of a simple solution like this, but it doesn't seem to work. [demo](http://dominikschreiber.com/gitignore-demo.png), was expecting `untracked files: foo/` – Dominik Schreiber May 06 '15 at 14:22