Search code examples
gitgitignore

Add .gitignore to gitignore


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


Solution

  • 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