If you already have the config/database.yml file in the repo and you want to ignore it. Follow these steps:
1. Add : config/database.yml to .gitignore file.
2. Rename database.yml to database.yml.sample
3. Check in the changes.
4. Now git will ignore the database.yml that you create in your project.