Add .gitignore to gitignore

user1125394 picture user1125394 · Apr 16, 2012 · Viewed 75k times · Source

Is it possible to add the .gitignore file to .gitignore itself?

.gitignore

Doesn't work though

I don't want to see it in edited files

Answer

Lars Nyström picture Lars Nyström · Apr 16, 2012

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 .gitignore, since it's supposed to be included in the repository.

If you want to ignore files in just one repository but want to avoid committing the ignore list (for example for personal files) you can add them to .git/info/exclude in that repository.

If you want to ignore certain files on every repository on your machine you can create the file ~/.gitignore_global and then run

git config --global core.excludesfile ~/.gitignore_global