简体   繁体   中英

git ignore everything except nested folder

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?

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

Ignoring everything, except baz and subfolders.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM