I've had issues with .gitignore also. I checked out the linked answers listed about, which fixed half the issue.
What really got gitignore working full for me was adding a comment on the first line of the file. Git wasn't parsing the exclude situated on the first line.