I'm trying to collect some of my default settings, and one thing I realized I don't have a standard for is .gitignore files. There's a great thread showing a good .gitignore for Visual Studio projects, but I don't see many recommendations for Python and related tools (PyGTK, Django).
So far, I have...
*.pyc *.pyo
...for the compiled objects and...
build/ dist/
...for the setuptools output.
What are some best practices for .gitignore files, and where can I go for more about these best practices?
A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .
gitignore file must be edited and committed by hand when you have new files that you wish to ignore. . gitignore files contain patterns that are matched against file names in your repository to determine whether or not they should be ignored.
You should put in . gitignore all files and patterns that are generated by the build system of your project, or any file that it might output while running. With this, it makes sure that nobody is committing compiled Python files.
The . gitignore file's purpose is to prevent everyone who collaborates on a project from accidentally commiting some common files in a project, such as generated cache files. Therefore you should not ignore .
Github has a great boilerplate .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/
When using buildout I have following in .gitignore
(along with *.pyo
and *.pyc
):
.installed.cfg bin develop-eggs dist downloads eggs parts src/*.egg-info lib lib64
Thanks to Jacob Kaplan-Moss
Also I tend to put .svn
in since we use several SCM-s where I work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With