当前位置:   article > 正文

python虚拟环境下 .gitignore 要忽略什么

python虚拟环境下 .gitignore 要忽略什么

Python虚拟环境中,.gitignore 文件用于告诉 Git 哪些文件和目录是不需要添加到版本控制中的。以下是一个典型的 Python 虚拟环境中 .gitignore 文件的内容:

  1. # Byte-compiled / optimized / DLL files
  2. __pycache__/
  3. *.py[cod]
  4. *$py.class
  5. # C extensions
  6. *.so
  7. # Distribution / packaging
  8. .Python
  9. env/
  10. venv/
  11. ENV/
  12. build/
  13. develop-eggs/
  14. dist/
  15. downloads/
  16. eggs/
  17. .eggs/
  18. lib/
  19. lib64/
  20. parts/
  21. sdist/
  22. var/
  23. wheels/
  24. pip-wheel-metadata/
  25. share/python-wheels/
  26. *.egg-info/
  27. .installed.cfg
  28. *.egg
  29. MANIFEST
  30. # PyInstaller
  31. # Usually these files are written by a python script from a template
  32. # before PyInstaller builds the exe, so as to inject date/other infos into it.
  33. *.manifest
  34. *.spec
  35. # Installer logs
  36. pip-log.txt
  37. pip-delete-this-directory.txt
  38. # Unit test / coverage reports
  39. htmlcov/
  40. .tox/
  41. .nox/
  42. .coverage
  43. .coverage.*
  44. .cache
  45. nosetests.xml
  46. coverage.xml
  47. *.cover
  48. .hypothesis/
  49. .pytest_cache/
  50. testlog/
  51. # Translations
  52. *.mo
  53. *.pot
  54. # Django stuff:
  55. *.log
  56. local_settings.py
  57. db.sqlite3
  58. db.sqlite3-journal
  59. # Flask stuff:
  60. instance/
  61. .webassets-cache
  62. # Scrapy stuff:
  63. .scrapy
  64. # Sphinx documentation
  65. docs/_build/
  66. # PyBuilder
  67. target/
  68. # Jupyter Notebook
  69. .ipynb_checkpoints
  70. # pyenv
  71. .python-version
  72. # celery beat schedule file
  73. celerybeat-schedule
  74. # SageMath parsed files
  75. *.sage.py
  76. # Environments
  77. .env
  78. .venv
  79. env.bak/
  80. venv.bak/
  81. # Spyder project settings
  82. .spyderproject
  83. .spyproject
  84. # Rope project settings
  85. .ropeproject
  86. # mkdocs documentation
  87. /site
  88. # mypy
  89. .mypy_cache/
  90. .dmypy.json
  91. dmypy.json
  92. # Pyre type checker
  93. .pyre/
  94. # pytype static type analyzer
  95. .pytype/
  96. # Cython debug symbols
  97. cython_debug/

这个列表不是固定的,它可能会根据你的项目和所使用的工具有所不同。例如,如果你使用的是其他数据库,你可能需要忽略其他数据库文件。如果你使用的是其他开发工具,你可能需要忽略由这些工具生成的特定文件或目录。

一般来说,你应该忽略以下内容:

  1. 虚拟环境文件夹(通常是 env/, venv/, .venv/ 等)。
  2. 编译生成的文件(如 .pyc 文件和 __pycache__ 目录)。
  3. 包分发文件夹(如 build/, dist/, *.egg-info/)。
  4. 安装器日志文件(如 pip-log.txt)。
  5. IDE 和编辑器配置文件(如 .idea/ 对于 PyCharm,.vscode/ 对于 Visual Studio Code)。
  6. 操作系统生成的文件(如 .DS_Store 对于 macOS,Thumbs.db 对于 Windows)。
  7. 测试和覆盖报告(如 .tox/, .coverage, .pytest_cache/)。
  8. 项目中特定的环境变量或配置文件(如 .env)。

创建适合你项目的 .gitignore 文件时,确保理解每个条目的目的,并根据你的项目需要进行调整。GitHub 提供了一个很好的资源库,其中包含了许多不同编程语言和框架的 .gitignore 模板,这可以作为一个很好的起点。

作者:汪汪队立大功
链接:https://juejin.cn/post/7332290436345937955

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/711721
推荐阅读
相关标签
  

闽ICP备14008679号