有什么方法可以查看为什么某些文件被 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