||dir-pattern file-pattern1 [file-patternN]||✔ dir pattern
✘ file patterns
The order of the commands in your template file matters. I recommend doing includes first, then excludes, going from most specific to most general.
Remember: You only need to exclude files get added to the list by default or
*with your include commands -- *you do not need to fully mirror your
.gitignore with exclude commands.
If a pattern is anchored that means it must match the root of the project precisely. For example, given these files:
. ├── LICENSE.txt └── things └── LICENSE.txt
- The command
include LICENSE.txtwould add
- The command
global-include LICENSE.txtwould add any
LICENSE.txtfound in the tree.
Thus you want to be certain to use a
global-exclude to keep out unwanted
files that get strewn about everywhere:
global-exclude *.py[cod] global-exclude .DS_Store
Shell-style glob patterns
||Match 0 or more anything but a path seperator, e.g.
||Match 1 of anything but a path seperator, e.g.
||Match anything, including path seperators.||
||Match any character within; ranges are valid.||
||Match anything except a character within; ranges are valid.||
Note: Older versions of Python did not support the globstar (
**). While it is a wonderful addition in newer version of Python and
setuptools, it can still take some playing with to get the result you want, particularly with
- Leading and trailing whitespace are irrelevant.
- Comments are an
#not escaped with a
\#would not start a comment.
- Lines can be continued using a
An example of some syntax is useful:
include LICENSE.txt # If you need a literal special glob character, put it in a sequence. include myfile[?].txt # To match a literal hash, escape it. include my\#file.txt graft docs global-exclude \ *.py[cod] \ # Comments after line continuations are valid. # And between line continuations as well! .DS_Store \ # Last item can have a line continuation as well, as long as the next line is blank. prune docs/build
For a real-world example, have a look at the included