Git忽略不在gitignore中的文件 [英] Git is ignoring files that aren't in gitignore
问题描述
我有一个忽略图像文件以及一些其他文件的git存储库,但是我的 .gitignore
文件只忽略了一个 config.php
文件。是否有某个我无法找到的全局忽略文件?我现在必须指定文件来添加它们,并且它给了我这个警告:
以下路径被您的.gitignore
我的〜/ .gitconfig
文件的内容只有我的电子邮件地址。
git check-ignore
使用 git check
例如:
$ git check-ignore -v config.php
.gitignore:2:src config.php
以上输出详细介绍了每个给定路径名(包括行)的匹配模式(如果有的话)。
$ b $因此,也许你的文件扩展名不会被忽略,但是整个目录。
返回的格式是:
<信源> <结肠癌和GT; < LINENUM> <结肠癌和GT; <模式> < HT> <路径名>
或者使用以下命令打印
.gitignore
在用户HOME和资料库文件夹中:
$ b
cat〜/ .gitignore$(git rev-parse - (git rev-parse --show-toplevel)/ .git / info / exclude
或者使用
git add -f
,它允许添加其他被忽略的文件。
请参阅:
man gitignore
,man git-check-ignore
了解更多详情。
语法
git check-ignore [选项]路径名...
git check-ignore [options] --stdin
I have a git repository that is ignoring image files as well as a few other files, but my
.gitignore
file only has it ignoring aconfig.php
file. Is there some global ignore file somewhere that I can't seem to find? I have to specify files to add them now, and it's giving me this warning:The following paths are ignored by one of your .gitignore files.
The contents of my
~/.gitconfig
file are only my e-mail address.解决方案
git check-ignore
Use
git check-ignore
command to debug your gitignore file (exclude files).For example:
$ git check-ignore -v config.php .gitignore:2:src config.php
The above output details about the matching pattern (if any) for each given pathname (including line).
So maybe your file extension is not ignored, but the whole directory.
The returned format is:
<source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>
Or use the following command to print your
.gitignore
in user HOME and repository folder:
cat ~/.gitignore "$(git rev-parse --show-toplevel)"/.gitignore "$(git rev-parse --show-toplevel)"/.git/info/exclude
Alternatively use
git add -f
which allows adding otherwise ignored files.See:
man gitignore
,man git-check-ignore
for more details.Syntax
git check-ignore [options] pathname…
git check-ignore [options] --stdin
这篇关于Git忽略不在gitignore中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!