After reading more than N introductions, the results are all in one sentence-clear at a glance ...... In fact, those examples do not cover common requirements, so I am very confused. Study for yourself.
Hgignore supports two syntaxes: Python/perl-style Regular Expressions and system shell. Although the shell syntax is clear at a glance, it is recommended to use Regexp. First, you do not need to specify the syntax in the file (the regular expression is the default syntax), and second, it is more controllable.
There are two common requirements: filter out specific types of files (usually by the suffix) and filter out files in a specific folder.
Filter the writing of a specific suffix
- /. Xxx $
"/." Is ".", because "." has a special meaning in the regular expression, so "/" must be added before escape. "$" Indicates the end, so the above expression indicates matching the file ended with ". xxx"
Filter the writing of a specific folder
- ^ Folder/
The path Separator of python is "/", which can be transplanted on different operating systems. "^" Indicates start. The complete file name is path/filename. Therefore, the above expression indicates that the file starts with "folder.