Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't git ignore .gitgnore?

Tags:

git

gitignore

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?

like image 895
Henrik Sommerland Avatar asked Dec 03 '25 09:12

Henrik Sommerland


2 Answers

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
like image 157
Haralan Dobrev Avatar answered Dec 04 '25 23:12

Haralan Dobrev


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.

like image 24
wumpz Avatar answered Dec 04 '25 22:12

wumpz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!