I hava a folder .idea/
in my repository, and it is on the .gitignore
list.
For some reason, I had used git add .idea/ -f
to force git add .idea
folder to my repos.
I just want to do this once.
But I found when I use git add .
in anther time, git still add .idea
's change to my repository. It is not my willing, How to solve this?
the thing is that .gitignore works for untracked files only. If the files inside .idea are already part of the project (because you added them on previous revisions) then git will start telling you when the files are modified even though it's inside .gitignore. What you can then do to avoid git from telling you about these files (assuming you want to keep them in the history of the project) is to force git to not care about them anymore. Than can be achieved with git update-index --assume-unchanged
. That is a 'per repo' operation so other developers will have to do the same on their repos as well.
https://git-scm.com/docs/git-update-index
As a side note, adding metadata like IDE files into the project is not considered a good idea but it's up to you.