我试图收集一些默认设置,我意识到我没有标准的一件事是.gitignore文件。有一个很棒的线程显示用于Visual Studio项目的。gitignore,但我没有看到很多关于Python和相关工具(PyGTK, Django)的建议。
到目前为止,我已经……
*.pyc *.pyo
...对于编译的对象和…
build/ dist/
...对于setuptools输出。
.gitignore文件的一些最佳实践是什么,我可以从哪里获得更多关于这些最佳实践的信息?
一个问题是,如果你也想使用git来完成你的项目。如果是这样的话,你可能想要从存储库中排除本地sqlite文件,同样的情况可能也适用于文件上传(主要是在你的媒体文件夹中)。(我现在说的是django,因为你的问题也带有django的标签)
local_settings.py,用于django项目。
*~为所有项目。
以下是其他一些可能被setuptools遗留的文件:
MANIFEST *.egg-info
当使用构建。时,我在.gitignore中有以下内容(以及*.pyo和*.pyc):
.gitignore
*.pyo
*.pyc
.installed.cfg bin develop-eggs dist downloads eggs parts src/*.egg-info lib lib64
感谢雅各Kaplan-Moss
我也倾向于把.svn放在里面,因为我们在我工作的地方使用了几个scm。
.svn
Github有一个伟大的样板。gitignore
# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] # C extensions *.so # Distribution / packaging bin/ build/ develop-eggs/ dist/ eggs/ lib/ lib64/ parts/ sdist/ var/ *.egg-info/ .installed.cfg *.egg # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports .tox/ .coverage .cache nosetests.xml coverage.xml # Translations *.mo # Mr Developer .mr.developer.cfg .project .pydevproject # Rope .ropeproject # Django stuff: *.log *.pot # Sphinx documentation docs/_build/
涵盖了大多数一般的东西
# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ 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/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 # 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/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/
参考:python .gitignore