Django 2 Web Development Cookbook
上QQ阅读APP看书,第一时间看更新

There's more...

With Git ignore files, we have the ability to follow a whitelist pattern rather than a blacklist, which means we can indicate what files we want to include rather than those we should omit. In addition, the patterns given in .gitignore are honored for all levels of the tree below where the file resides, making them extremely powerful. For example, the file could be written in this manner for a Docker project:

# .gitignore
# ignore everything in the root by default
/*
# allow this file of course
!.gitignore
# allowed root directories
!/apps/
!/bin/
!/config/
!/data/
!/project/
!/static/
!/templates/
# allowed root files
!/Dockerfile
!/docker-compose.yml
# files allowed anywhere
!README.md
# specifically ignore certain deeper items
__pycache__/