Providing proper .gitignore file for your repository should be one of first commits. Obviously the file may evolve over the time as your project and development, build, test and deployment environments are changing. Nevertheless – especially in case of open source projects hosted publicly – proper .gitignore file can prevent leaking confidential information. Secondly distributing useless, orphaned or intermediate files being a result of a (sometimes failed) build process is clobbering your branches and can’t be treated as a good practice. Not to mention that later you waste both bandwidth and storage when other users clone your repository.
First lets disable tracking of python compiled bytecode files:
# ignore python compiled files *.py[cod]
That was quick and simple. Now let’s assure not IDE related files will be added to the repository as well. Below example assumes ActiveState Komodo Edit :
# ignore komodo project files *.komodoproject
Tweak this example to your particular IDE files. Now we can deal with unittest temporary files:
# ignore temp unittest files @test_*_tmp
Some tests may require additional input data. You could pass it manually every time you run tests but that would be completely pointless. Instead we can provide data in dedicated file(s) but since data can contain confidential information like passwords or keys we don’t want it to be leaked into the repository as well. In below example test/vars4tests.py contain all data required during running unit tests:
# ignore variables for unit tests test/vars4tests.py
Last but not least, there is no point in adding your virtualenv directories as well. In below example virtualenv directory structure is located in venv/.
# ignore virtulenv directory venv/