Article Directory
Official website in different languages .ignore
:
https://github.com/github/gitignore/tree/main
rule
basic rules
- Use
#
as comment - In
.gitignore
a file, each line represents a pattern; - Empty lines do not match any files;
- git tracks files, not directories;
.gitignore
Even setting ignore in has no effect if the local repository file is already tracked ..gitignore
The files will also be uploaded to the remote warehouse, so people in the same warehouse can use the same.gitignore
file.
ignore files and directories
folderName
- Indicates that the folderName file and folderName directory are ignored, and
src/folder
the files andsrc/utils/folder
files will be ignored, that is, they will not be submitted to the remote warehouse. - Will automatically search multi-level directories, such as:
*/*/folderName
.
Ignore folderName files only, not folderName directories (!)
The schema looks like this:
folderName
!folderName/
- Reverse operation
!
: Indicates that the previously ignored matching pattern is included in the trace content again. - src/folderName files, src/utils/folderName files will be ignored, and folderName directories with the same name will not be ignored.
just ignore the directory /
folderName/
Ignore folderName directories, including:
- The foldernName under the current directory, for example:
folderName/
; - folderName under the multi-level directory, for example:
*/*/folderName/
; - src/folder files and src/utils/folder files with the same name are not ignored.
Use wildcards * ? []
Commonly used wildcards are:
- Asterisk
*
: match multiple characters; - Question mark
?
: match any character/
except ; - Square brackets
[xxxx]
: match characters in multiple lists;
$ tree
.
├── src
│ ├── add.c
│ ├── add.i
│ └── add.o
├── test.c
├── test.i
└── test.o
1 directory, 6 files
Among them, the contents of the .gitignore file are as follows:
*.[io]
- So in the local warehouse,
test.i
file,test.o
file,src/add.o
file,src/add.i
file will be ignored test.c
Files and files are notadd.c
ignored.- The matching patterns ignored here are multi-level directories.
Multi-level directory**
A slash followed by two consecutive asterisks **
indicates a multi-level directory.
src/**/file
It can mean ignore src/folder1/file
, src/folder1/folder2/***/foldern/file
etc.
2023-07-29 (Sat)