赞
踩
在Python虚拟环境中,.gitignore
文件用于告诉 Git 哪些文件和目录是不需要添加到版本控制中的。以下是一个典型的 Python 虚拟环境中 .gitignore
文件的内容:
- # Byte-compiled / optimized / DLL files
- __pycache__/
- *.py[cod]
- *$py.class
-
- # C extensions
- *.so
-
- # Distribution / packaging
- .Python
- env/
- venv/
- ENV/
- build/
- develop-eggs/
- dist/
- downloads/
- eggs/
- .eggs/
- lib/
- lib64/
- parts/
- sdist/
- var/
- wheels/
- pip-wheel-metadata/
- share/python-wheels/
- *.egg-info/
- .installed.cfg
- *.egg
- MANIFEST
-
- # 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/
- .nox/
- .coverage
- .coverage.*
- .cache
- nosetests.xml
- coverage.xml
- *.cover
- .hypothesis/
- .pytest_cache/
- testlog/
-
- # Translations
- *.mo
- *.pot
-
- # Django stuff:
- *.log
- local_settings.py
- db.sqlite3
- db.sqlite3-journal
-
- # 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
-
- # Environments
- .env
- .venv
- env.bak/
- venv.bak/
-
- # Spyder project settings
- .spyderproject
- .spyproject
-
- # Rope project settings
- .ropeproject
-
- # mkdocs documentation
- /site
-
- # mypy
- .mypy_cache/
- .dmypy.json
- dmypy.json
-
- # Pyre type checker
- .pyre/
-
- # pytype static type analyzer
- .pytype/
-
- # Cython debug symbols
- cython_debug/
这个列表不是固定的,它可能会根据你的项目和所使用的工具有所不同。例如,如果你使用的是其他数据库,你可能需要忽略其他数据库文件。如果你使用的是其他开发工具,你可能需要忽略由这些工具生成的特定文件或目录。
一般来说,你应该忽略以下内容:
env/
, venv/
, .venv/
等)。.pyc
文件和 __pycache__
目录)。build/
, dist/
, *.egg-info/
)。pip-log.txt
)。.idea/
对于 PyCharm,.vscode/
对于 Visual Studio Code)。.DS_Store
对于 macOS,Thumbs.db
对于 Windows)。.tox/
, .coverage
, .pytest_cache/
)。.env
)。创建适合你项目的 .gitignore
文件时,确保理解每个条目的目的,并根据你的项目需要进行调整。GitHub 提供了一个很好的资源库,其中包含了许多不同编程语言和框架的 .gitignore
模板,这可以作为一个很好的起点。
作者:汪汪队立大功
链接:https://juejin.cn/post/7332290436345937955
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。