这是我当前目录的内容。.gitignore遵循什么模式?
$ ls
foo.foo
$ ls -a
. .. .bar.foo .foo foo.foo .gitignore
然后我把这个目录变成一个git仓库。
$ git init
Initialized empty Git repository in /home/lone/foo/.git/
$ ls -a
. .. .bar.foo .foo foo.foo .git .gitignore
这里是.gitignore
的内容。
$ cat .gitignore
*.foo
我看到,在.gitignore
模式从外壳相同的模式不同的行为方式。在外壳*.foo
只匹配非隐藏文件,即不以句点开头的文件名。
$ echo *.foo
foo.foo
但*.foo
在.gitignore
似乎匹配任何文件,隐藏或不隐藏,与.foo
结束。
$ git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
nothing added to commit but untracked files present (use "git add" to track)
我在哪里可以了解更多有关的.gitignore遵循模式的准确定义,所以我能理解为什么它的行为不同于shell glob模式的不同?
这是一个资源:https://git-scm.com/docs/gitignore。在某些情况下,它的处理方式与壳体水珠完全相同。 “否则,Git的对待方式看作是适合于消费的fnmatch壳水珠(3)与FNM_PATHNAME标志”(但读它上面的东西,因为当它没有) – hiandbaii
@hiandbaii我没有问这个问题之前阅读该文档。但是,有几件事我不清楚。 shell是否也使用'fnmatch(3)'来处理glob模式?在那种情况下,为什么'*'在'.'(即隐藏文件)之前不匹配零个字符,但gitignore呢?我无法找到解释这个问题的'gitignore'文档中的精确部分。 –