忽略文件
一般,总有些文件无须纳入Git管理,比如日志文件,或者编译过程创建的临时文件等。此时,可以使用.gitignore 文件列出忽略文件模式
$ cat .gitignore
*.[oa]
*~
文件.gitignore 格式规范:
所有空行或以#开头的行都会被Git忽略
可以使用标准的glob模式匹配
匹配模式可以以/开头防止递归
匹配模式可以以/结尾指定目录
忽略指定模式之后的文件,可以在模式前加上!取反
# no .a files
*.a
# but do track lib.a, even though you're ignoring .a files above
!lib.a
# only ignore the TODO file in the current directory, not subdir/TODO
/TODO
# ignore all files in the build/ directory
build/
# ignore doc/notes.txt, but not doc/server/arch.txt
doc/*.txt
# ignore all .pdf files in the doc/ directory
doc/**/*.pdf