When would you use .git / info / exclude instead of .gitignore to exclude files?

I'm a little confused about the pros and cons of using .git/info/exclude and .gitignore to exclude files.

Both of them are at the repository / project level, so how are they different and when should we use .git/info/exclude ?

+97
git gitignore
Apr 7 '14 at 8:09
source share
4 answers

The advantage of .gitignore is that it can be checked in the repository itself, unlike .git/info/exclude . Another advantage is that you can have multiple .gitignore files, one inside each directory / subdirectory for ignore rules for a particular directory, as opposed to .git/info/exclude .

So .gitignore is available for all repository clones. Therefore, in large teams, all people ignore files of the same type Example *.db , *.log . And you may have more specific ignore rules due to multiple .gitignore .

.git/info/exclude is available only for individual clones, so what one person ignores in his clone is not available in the frame of another person. For example, if someone uses Eclipse for development, it might make sense for this developer to add the .build folder to .git/info/exclude , because other developers may not use Eclipse.

In general, file / ignore rules that should be completely ignored should go to .gitignore , otherwise files that you want to ignore only on the local clone should go to .git/info/exclude

+132
Apr 07 '14 at 8:15
source share

Google: 3 ways to exclude files

  1. .gitignore is applied to each clone of this repository (versioned, everyone will have it),
  2. .git/info/exclude only applies to your local copy of this repository (local, not shared with others),
  3. ~/.gitignore applies to all repositories on your computer (local, not accessible to others).

3. actually requires configuration on your computer:

 git config --global core.excludesfile '~/.gitignore' 
+24
Apr 7 '14 at 8:14
source share

Just to offer our (real world) experience: we started using .git / info / exclude when we had to configure some configuration files in each development environment, but still wanted the source to be supported in the repo and accessible to other developers,

Thus, local files that have been cloned and modified can be excluded from commits without affecting the source files in the repo, but not necessarily ignored in the repo.

+11
Mar 07 '17 at 11:35
source share

Use .gitignore to ignore project-specific rules. Use an exclude or global ignore file to ignore rules specific to your environment.

For example, my global ignore files ignore temporary files generated by any editor that I use - this rule is specific to my environment and may be different for some other developers in the same project (maybe they use a different editor). Oto, my project .gitignore files ignore things like API keys and create artifacts for the project, and should be the same for everyone on the project.

It helps?

+2
Jun 14 '18 at 5:56
source share



All Articles