Understanding the Structure of the dsrepoignore File
This section explains how the dsrepoignore file is structured.
Rules for Defining the dsrepoignore File
To create a dsrepoignore file, you must understand how the file is structured for processing.
- Lines that begin with a hash character (
#) are ignored and can be used to add comments for readability. - Blank lines do not match any files or folders and can be used to separate sections to improve readability.
- The backslash (
\) character is used to escape processing. - Spaces at the end of the line (trailing spaces) are ignored unless they are escaped with the escape character.
- The slash
/is used as the directory separator. Slashes can occur at the beginning, middle, or end of the ignore pattern. If there is a slash at the beginning or middle of the pattern, then the pattern is relative to the directory level of the particular.dsrepoignorefile. If there is no slash at the beginning, the pattern matches at the current.dsrepoignorelevel or any level below the current level. If there is a slash at the end of the pattern, then the pattern only matches directories; otherwise the pattern can match both files and directories. - A question mark (
?) matches any single character except a slash. - A range notation, for example (
[a-zA-Z]or[1-10]), matches any single character in the range. - An asterisk (
*) matches anything except a slash. The next set of rules involves how the asterisk is processed with the slash character indicating directories. Any other instances of multiple asterisks are treated as if the asterisk was a single character. - A pattern with a leading
**/matches all directories. For example,**/userguidematches a file or directory nameduserguideanywhere. The pattern**/doc/userguidematches the file or directoryuserguideonly when it is directly under thedocdirectory. - A pattern concluding with
/**matches everything inside the preceding directory. For example,doc/**matches all files inside the directorydocrecursively starting at the level of the.dsrepoignorefile. - A pattern with slashes surrounding the double asterisk (
/**/) matches zero or more directories. For example, the patterndoc/**/userguidematchesdoc/userguide,doc/version1/userguide, regardless of how many directories of separation there are between the strings. - The exclamation point (
!) character negates the pattern that follows. This can be useful if you have a pattern that is excluded, but then you want to include a subset of that pattern. For example, if you want to exclude all *.log files except any that match *report.log.