Why doesn't git ignore .gitignore? Is this a bug or is this a feature? I can't see any reason why one would like to share ones .gitignore file. It feels a bit ironic to have to add .gitignore to .gitignore.
Is there any reason for this?
In short - it's a feature.
.gitignore is not meant as a local file for every developer on a project.
You need to ignore files and folders which are not meant to be committed to the repo by anyone.
Examples: build folders, vendor folders (installed via a package manager - e.g. node_modules), binary files.
Here is a nice help article from GitHub: https://help.github.com/articles/ignoring-files
You could also check out the github/gitignore repository for examples.
E.g. Symfony2 .gitignore is ignoring logs, cache, uploads, vendor libraries installed via composer and commonly used binaries like composer.phar:
# Bootstrap
app/bootstrap*
# Symfony directories
vendor/*
*/logs/*
*/cache/*
web/uploads/*
web/bundles/*
# Configuration files
app/config/parameters.ini
app/config/parameters.yml
# Composer
composer.phar
This is a feature. For example in Java you want to ignore all *.class files. So every user of your repository have to ensure, that no *.class files are committed. Therefore this is a usecase where this .gitignore should be available to all users of this repository.
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