If the file is already being tracked on git, you must first delete it (the physical file must be placed in the git folder for a while), commit the changes and add the file to the folder again. Then git will start to ignore it using your instruction.
Factory girl
source share