Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I do about user-specific config files (example: .idea/)?

Tags:

git

config

I've got some config files (.idea/) from an IDE in my working directory, and Git lists these as Untracked files. Should I

  1. add these to the .gitignore (which will get pushed to the main repo), or
  2. use the local option of

    git update-index --assume-unchanged <name of file>
    
  3. or follow a different approach altogether?

What's best practice?

like image 425
Snowcrash Avatar asked Sep 13 '25 21:09

Snowcrash


2 Answers

Those files are specific to your own machine/setup. You should indeed ignore them.

However, you should not simply add entries corresponding to those files in the project's .gitignore. Instead, you should ignore those files via a global .gitignore:

git config --global core.excludesfile <path-to-global-ignore-file>

Why not just add entries in the project's .gitignore? Remember that this file is going to be used by all collaborators in the project, so you want to keep it clean and tidy; adding user-specific entries to a repository-specific .gitignore will just bloat/pollute the latter, and contribute to unnecessary mental overhead.

For instance, imagine that one collaborator, Bob, works on Mac OS X, whereas another collaborator, Alice, works on Windows. Bob probably wants to ignore .DS_Store files, whereas, Alice probably wants to ignore thumbs.db files. However, Bob has no need to ignore thumbs.db files, and Alice has no need to ignore .DS_Store files. Therefore, they shouldn't inflict a useless gitignore entry on each other. They would do better to ignore such files via a .gitignore file local to their machines.

like image 50
jub0bs Avatar answered Sep 16 '25 10:09

jub0bs


The .idea folder and its associated .iws, .ipr, and .iwl files are really meant for your machine only. The best practice is to add them to .gitignore.

like image 35
Makoto Avatar answered Sep 16 '25 11:09

Makoto