22 April 2011

Today I had a horrid 15min trying to figure out why git isn’t ignoring my database config file inspite of adding that to the repo’s .gitignore. I dug through the .gitignore files of all my other repos and it seemed like I had done everything right but still the file I asked git to ignore wasn’t being ignored.

Finally, found out what caused the issue. Me. I had already added the database config file to a repo. I should have added it to the .gitignore file even before trying to make my first commit. It seems that git tracks all files you add to it before adding it to .gitignore. So you’ll have to remove it from git’s cache when you add it to the .gitignore.

git rm --cached config/database.yml