If it got added to your git repo before you specified it in the ignore
file, I think you have to remove it:
git rm config/database.yml
git commit -a -m “Removed database.yml”
(maybe save a backup of your database.yml first
What I do is rename database.yml to example_database.yml before the
initial commit to git (and have config/database.yml in .gitignore. Then
after the initial commit I copy example_database.yml back to
database.yml, which will not be ignored.
Git will only ignore untracked files that are in .gitignore. If you are
tracking changes to a file the .gitignore has no effect.
The reason I keep example_database.yml in Git is so that when the
repository is cloned all I have to do is copy example_database.yml to
database.yml and I’m ready to go in the clone.
Note: this way each developer can keep their database password in their
own untracked copy of database.yml if a password is required. But, they
won’t have to recreate database.yml from scratch.