git - 为什么 git 会忽略不在 .gitignore 文件中的文件?

标签 git gitignore

我有一个忽略图像文件以及一些其他文件的 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 gitignoreman git-check-ignore

语法

git check-ignore [options] pathname…​

git check-ignore [options] --stdin

关于git - 为什么 git 会忽略不在 .gitignore 文件中的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9436405/

相关文章:

git:将子树从一个分支 merge 到另一个分支

git - 我怎样才能把它放到 "git push"推送到本地存储库的地方?

GWT .hgignore/.gitignore 条目

git - 如何 git 忽略存储库中任何位置的 ipython 笔记本检查点

git - 忽略具有给定名称和扩展名的所有文件

git - 如何排除文件被 merge 到其他git分支?

混帐 : Determine if branch is in a merge conflict state

git - 理解 git push 命令

node.js - .gitignore 和 node_modules

Git:不要忽略带有点的目录