How to ignore files only on my machine?

If we want to ignore files (they will not suggested to be added as staged) we usually use .gitignore in root folder of our repository. There is one problem this file is shared between all contributers of that repository.

What to do when we want add filter only on our machine? For example only we use somekind tool or extension which generates some sort of files.

We have two options.

exclude file for local repository

When you go to a <repository_location>/.git/info/exclude, if file doesn’t exists create one.

That file behavies exactly like .gitignore.

gitignore system wide

You need to set git config for global .gitignore file, by doing running command:

git config --global core.excludesFile "c:/users/soltys/.gitignore"

That file behavies exactly like .gitignore.

Order of reading gitignore files

  1. Pattern given add command itself
  2. .gitignore in repository as close as possible to given file
  3. .git/info/exclude
  4. file set by config in variable core.excludesFile

Sources

Programista, domowy kucharz i "amator amerykańskiej polityki". Zbieram informacje z całej sieci, po odrzuceniu chwastów i dodaniu swojej opinii publikuje na blogu.