我有一个忽略图像文件以及一些其他文件的 git 存储库,但我的 .gitignore
文件只忽略了 config.php
文件。是否有一些我似乎找不到的全局忽略文件?我现在必须指定要添加的文件,它给了我这个警告:
The following paths are ignored by one of your .gitignore files.
我的 ~/.gitconfig
文件的内容只是我的电子邮件地址。
最佳答案
git 检查忽略
使用git check-ignore
command调试你的 gitignore 文件(排除文件)。
例如:
$ git check-ignore -v config.php
.gitignore:2:src config.php
关于每个给定路径名(包括行)的匹配模式(如果有)的上述输出详细信息。
所以也许你的文件扩展名没有被忽略,而是整个目录。
返回格式为:
<source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>
或者使用以下命令在用户 HOME 和存储库文件夹中打印你的 .gitignore
:
cat ~/.gitignore "$(git rev-parse --show-toplevel)"/.gitignore "$(git rev-parse --show-toplevel)"/.git/info/exclude
或者使用 git add -f
允许添加其他忽略的文件。
有关详细信息,请参阅:man gitignore
、man git-check-ignore
。
语法
git check-ignore [options] pathname…
git check-ignore [options] --stdin
关于git - 为什么 git 会忽略不在 .gitignore 文件中的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9436405/