Ignoring .gitignore config/database.yml in a rails project
Solution 1
database.yml
is the proper place for configuring your database credentials. Normally you'd commit database.yml
while only configured with your development and testing environments.
I don't have passwords on my local Postgres and MySQL instances so I can safely commit database.yml
. If you want to ignore it, just add database.yml
line to the end of your .gitignore
file. You'll need to make sure it's cleaned up and committed before ignoring it. Then you can make your changes safely.
Once you deploy to production you would symlink it in from a copy already stored on that server with the sensitive credentials.
Solution 2
You should'nt have passwords in your database.yml....I don't. Why do you have passwords? If you deploy to heroku read: http://devcenter.heroku.com/articles/config-vars
If you still want to ignore it add:
echo "database.yml" >> .gitignore
Related videos on Youtube
Mikey Hogarth
Updated on June 04, 2022Comments
-
Mikey Hogarth almost 2 years
When working on rails project (I'm still in the "beginner" phase of learning at the moment by the way) the file config/database.yml seems to be the one where things like database passwords etc. go. However, nobody seems to recommend putting it in the .gitignore file - why?
Surely I would need to exclude this or my sensitive database configuration details would end up being public knowledge if I pushed to github.
-
daniel over 12 yearsWell I don't have any passwords in my database.yml, I told you, I use env variables in deployment. If you have passwords in database.yml, then yes add it to the .gitignore.