Adding a .gitignore to an Existing Repo
Posted on February 27th, 2014
I ran across this issue earlier in the week, where I was working in a repository that didn't have a .gitignore. There were multiple directories and files I wanted leave out of the repo, but they were already commited and pushed. After browsing for a solution onStackOverflowon how to remove files from a repo that are now in my .gitignore, I found this solution.
You can also remove individual files, if you don't want such a drastic approach:
git rm --cached filename
Then add your changes again, commit, and push.
If you continue to have issues, I recommend navigating to the link at the bottom and see other answers some users had on StackOverflow.