0

I have tst.prop file in my project directory and I don't want commit it to repository. I have placed line *.prop in .git/info/exclude. When I type git status command I still have line:

modified: tst.prop 

Why it is still there? How to solve this problem?

vico
  • 17,051
  • 45
  • 159
  • 315
  • 1
    Possible duplicate of [Ignore files that have already been committed to a Git repository](http://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository) – axiac Dec 15 '16 at 14:22

1 Answers1

0

It is explained in the first paragraph of the documentation of the gitignore file:

A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected.

Since git status reports your file as modified it means Git already tracks the file (it was added and committed in the past).

In order to force Git forget about it you have to add its removal to the index (the area where Git prepares the next commit) then commit the change:

git rm --cached tst.prop
git commit

However, because you put the file in .git/info/exclude, in the future Git will remove it only on your local repository. After they pull the latest changes (the removal of the file) from the central repository, your collaborators will have the file as "untracked" and, most probably, they will add it again to the repo.

If you want to make Git ignore the file for everybody that works to the project you have to put it in .gitignore then add .gitignore to the repository and commit it. And don't forget to remove the file from the index, as explained above.

axiac
  • 68,258
  • 9
  • 99
  • 134