The format specification of the file .gitignore is as follows:
All empty lines or lines starting with # will be ignored by Git.
Can use standard glob pattern matching.
The matching pattern can start with (/) to prevent recursion.
The matching pattern can specify a directory ending with (/).
To ignore files or directories outside the specified pattern, you can negate it by adding an exclamation mark (!) before the pattern.
The so-called glob pattern refers to the simplified regular expression used by the shell. Asterisk (*)匹配零个或多个任意字符;[abc] 匹配任何一个列在方括号中的字符(这个例子要么匹配一个 a,要么匹配一个 b,要么匹配一个c);问号(?)只匹配一个任意字符;如果在方括号中使用短划线分隔两个字符,表示所有在这两个字符范围内的都可以匹配(比如 [0-9]表示匹配所有 0 到 9 的数字)。 使用两个星号(*) 表示匹配任意中间目录,比如a/**/z 可以匹配 a/z, a/b/z 或a/b/c/zetc.
Try it without adding '/' after 11: !/upload/2011/11
[Reference link]: Ignoring Files/Ignoring Files
Any level
.gitignore
一般用我们使用git add .
这种命令中没有明确指定要加入的文件时忽略.gitignore
中声明的文件,但以!
Rules starting withwill not be excluded.
This combination can simplify the syntax..gitignore
的复杂度,如果没有!/path
You have to write all the files and directories except /2011/11/.
Example: The teacher announces the full score of this time
🎜Of course it can also be done like this🎜