The short answer is no. The .gitignore
facilities only prevent files from being tracked in the first place. In other words, it prevents files from entering the repository for the first time. However, once a file is tracked, it is tracked forever. All changes to that file will be tracked.
There are two general solutions. (1) Avoid adding that file to the index ever. This is just a matter of policy. (2) Place all such ignored files in an archive like UnzipMeRightAfterCloning.zip
. It's an extra step for people getting into the repo, but at least the target files will never be committed.