I've got some config files (.idea/
) from an IDE in my working directory, and Git lists these as Untracked files
. Should I
- add these to the
.gitignore
(which will get pushed to the main repo), or use the local option of
git update-index --assume-unchanged <name of file>
- or follow a different approach altogether?
What's best practice?
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
: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 ignorethumbs.db
files. However, Bob has no need to ignorethumbs.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.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
.IDE specific files should always be ignored. Unless maybe everyone in your team is working with the same IDE, then it might be useful keeping some. But most of the time it's not.
If you choose to 'remove' them locally, there is always the risk of someone forgetting to do that, so it might be best to just put it in a gitignore.
Here is a list of IDE specific gitignore files that you can use
https://github.com/github/gitignore/tree/master/Global