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

fou*_*rth 12 git github gitignore

我试图在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
Run Code Online (Sandbox Code Playgroud)

这是我的 .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/
Run Code Online (Sandbox Code Playgroud)

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

任何有关为什么我的文件夹没有被添加的见解将不胜感激!:) 谢谢!

你想要的完整网址 /Users/shen/Desktop/New Platform/iceberg/static/icon

jsa*_*ryd 36

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

git check-ignore -v path/to/check
Run Code Online (Sandbox Code Playgroud)

更多信息在man git-check-ignore

  • 也使用“--no-index” (7认同)

Eri*_*kMD 5

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

但在这种情况下(当默认情况下忽略文件并且您仍然想添加它时),您始终可以执行以下操作:

git add -v -f iceberg/static/icon
Run Code Online (Sandbox Code Playgroud)

该标志是--force-f的快捷方式 (该标志意味着--verbose,这在使用时通常是一个有用的模式)
-vgit add


daG*_*aGo 5

我遇到了类似的问题,这就是我解决它的方法:

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

[core]
  excludesfile = /home/userName/.gitignore
Run Code Online (Sandbox Code Playgroud)

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