有什么方法可以看到为什么一些文件被git忽略(即.gitignore
文件中的哪个规则导致文件被忽略)?
假设我有这样(或者一个更复杂的场景,有数百个文件夹和数十个.gitignore
文件:
/
-.gitignore
-folder/
-.gitignore
-subfolder/
-.gitignore
-file.txt
如果我运行git add folder/subfolder/file.txt
, git可能会抱怨它被忽略:
The following paths are ignored by one of your .gitignore files:
folder/subfolder/file.txt
Use -f if you really want to add them.
有没有办法知道所有可能的.gitignore
中有一个规则来忽略这个文件,并显示该规则?如:
The following paths are ignored by your folder/.gitignore file (line 12: *.txt)
folder/subfolder/file.txt
Use -f if you really want to add them.
或者是:
$ git why-is-ignored folder/subfolder/file.txt
folder/.gitignore:12:*.txt