简体   繁体   中英

.gitignore in cakephp: ignore everything but files which are named empty

the cakephp project is using so called empty files. empty files are literally named empty and had no information inside.Their only purpose: Empty directories can be commited by versionising via git.

Unfortunately, I have a problem with the /app/tmp directory since it not only includes those empty files but also temporary cached files which shouldnt be indexed at all!

So I try to write a .gitignore file which should ignore everything in /app/tmp but not empty files, here's my not working attempt:

#.gitignore in cakephp root
/app/tmp
!/app/tmp/logs/empty
!/app/tmp/sessions/empty
!/app/tmp/tests/empty
!/app/tmp/cache/models/empty
!/app/tmp/cache/persistent/empty
!/app/tmp/cache/views/empty

What am I missing? Is .gitignore maybe not cappable to so something like this?

Thanks in advance!

Why not just add !empty to the root .gitignore ? Git will apply ignore rules recursively, from repo root to the end-directory. So if you have !empty in root ignore rules, it will be applied everywhere without any repeatitions.

The problem may be if app/tmp contains only ignored file (with any folding level). In this case git will not index app/tmp as it indexes only actualy existing files .

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