.gitignore官网
Ignore file changes with Git
.gitignore 文件用法
举例
栗子1 ???
The pattern “foo/*”, matches “foo/test.json” (a regular file), “foo/bar” (a directory), but it does not match “foo/bar/hello.c” (a regular file), as the asterisk in the pattern does not match “bar/hello.c” which has a slash in it.????
未验证成功!!!
栗子2:除了…,忽略所有
It is not possible to re-include a file if a parent directory of that file is excluded.
Example to exclude everything except a specific directory foo/bar
(note the /*
- without the slash, the wildcard would also exclude everything within foo/bar):
$ cat .gitignore
# exclude everything except directory foo/bar
/* # 除了foo/bar下的文件或文件夹,排除所有的文件或文件夹?
!/foo # 不排除foo文件夹
/foo/* # 排除foo文件夹下的所有文件
!/foo/bar # 不排除foo/bar文件夹
栗子3:除了…,忽略所有
文件夹结构
uploads
…|----avatar
…|…|----default_a.jpg
…|…|----default_b.jpg
…|…|----default_c.jpg
…|----article
…|----girl
uploads/*
!uploads/avatar/
uploads/avatar/*
!uploads/avatar/default*
忽略 uploads 文件夹下的所有文件,但是保留 avatar 目录下的 default*的文件跟踪
foo/*
与'foo/*'
的差异
rm .gitignore
echo foo/* >> .gitignore
cat .gitignore # 结果是,foo/bar foo/test.json
rm .gitignore
echo 'foo/*' >> .gitignore
cat .gitignore # 结果是,foo/*