git – How to ignore files in local repository only?

Question:

I keep files in my project working folder that are not subject to version control (such as pictures of cats). I would like to ignore them. But this requires changing .gitignore, which is common to all developers. I can’t do this or don’t want to (for example, so as not to give out cats).

Is it possible to somehow configure ignore only for my repository?

Answer:

Yes, this is possible by configuring the .git/info/exclude file. It .gitignore in the same way as a regular .gitignore , but is not included in the commit, and therefore is not passed along with the clone , push , pull commands.

$ open .git/info/exclude

#hide my cats
cats/

Or in one action:

echo -e '\n#hide my cats\ncats'>>.git/info/exclude
Scroll to Top