If you are working on a lot of Python projects and are using Git version control, it is very convenient to set up a global .gitignore file that ignores often occurring file types like .pyc and .egg that you generally don’t want to have in your repository.
Ignoring common python files not wanted in your repository
First make a file .gitignore in your home directory (
touch ~/.gitignore) and include the following:
.DS_Store *.py[cod] # C extensions *.so # Packages *.egg *.egg-info dist build eggs parts bin var sdist develop-eggs .installed.cfg lib lib64 # Installer logs pip-log.txt # Unit test / coverage reports .coverage .tox nosetests.xml # Translations *.mo # Mr Developer .mr.developer.cfg .project .pydevproject
Then make sure to add this .gitignore file to Git with the following command:
git config --global core.excludesfile '~/.gitignore'
If all went right, now files like .pyc and .egg are not included in Git repositories!