以下路径被您的 .gitignore 文件之一忽略

The following paths are ignored by one of your .gitignore files

我尝试将文件夹 iceberg/static/icon 添加到我的存储库中,但失败并出现错误:

shen-3:New Platform shen$ git add iceberg/static/icon
The following paths are ignored by one of your .gitignore files:
iceberg/static/icon

这是我的 .gitignore。我真的很困惑,我不明白哪个项目与我的文件匹配。

hello/
deploy_server/
gunicorn_start
Vida.env/

# IDE conf
.idea/
.vscode/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
staticfiles/
local_settings.py
migrations/

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

发生这种情况还有其他原因吗?

如能深入了解我的文件夹未被添加的原因,我们将不胜感激! :) 谢谢!

满url你想要/Users/shen/Desktop/New Platform/iceberg/static/icon

我不确定你的 .gitignore 是哪一行触发了忽略。

但在这种情况下(当一个文件被默认忽略,而你又想添加它时),你总是可以执行以下操作:

git add -v -f iceberg/static/icon

-f 标志是 --force
的快捷方式 (并且 -v 标志表示 --verbose,这在使用 git add 时通常是一种有用的模式)

将以下行添加到您的 .gitignore

!iceberg/static/icon

爆炸 (!) 表示将其包含在 .gitignore

:)

要检查导致特定路径被忽略的 gitignore 规则,运行 git check-ignore:

git check-ignore -v path/to/check

更多信息请见 man git-check-ignore

我遇到过类似的问题,我是这样解决的:

很可能您在 ~/.gitignore 处有一个全局 .gitignore 文件。在你的 ~/.gitconfig 文件中有这样一行:

[core]
  excludesfile = /home/userName/.gitignore

从您的配置中删除该行应该可以解决上述问题。 要让 Git 忽略 all 存储库中的某些文件,您可以将该行添加回全局 .gitconfig.

在其他答案之外添加此答案,以防万一它对某人有帮助 - 就我而言,我抱怨:

The following paths are ignored by one of your .gitignore files:
lol/foo/include
lol/foo/baz/include

我的 .gitignore 有:

include/

从 .gitignore 中删除该行解决了我的问题。

这告诉我的是,即使您的 违规路径 有一个 partial/sub 路径 directory/sub-directory 在 .gitignore 的某个地方,那么它也将被忽略。

我检查了你的 .gitignore 文件。它不包含任何“iceberg”或“static”(虽然有“staticfiles/”但那不重要)或“icon”。

顺便说一句,您可能还想搜索当前 .gitignore 中的 any 路径中是否还有其他“.gitignore”文件。但我不能 100% 确定这是否确实是您的问题。

我遇到了同样的问题,我设法找到了一个简单的解决方案。

手册 git -h 中有一节介绍了选项 -f

-f, --force "Allow adding otherwise ignored files"

然而,我猜到了并且令人惊讶地成功了!

在终端输入:git add -f "the path"