Git and Rails: ignore database.yml

Finally, I took a great step by abandoning SVN for Git and loving it. It should be somewhere, but I canโ€™t find how to do it, friendly.

I have my repo site stored on a remote machine. I click on my working copy and extract this data to the production machine. One mayors difference, although this is a โ€œsingleโ€ file: database.yml, which will never be modified on a production machine.

Is it possible (and if so, how) when the data is extracted from the repo in order to โ€œignoreโ€ only this file? I do it manually at this moment, but some elegance would be most appreciated.

Thanks.

+7
git gitosis macos
source share
4 answers

My advice: don't even put it in git. Do database.yml.skel or something like that so that the user can simulate their own database.yml , keeping in mind the pattern. However, in my opinion, conf files are not part of version control - for the very reason that you mention.

Ignoring is very simple: there are actually several ways to do this. The right one for this is the .gitignore file; the other is .git/info/excludes . See this answer for more details.

So, from the head:

 echo database.yml >> config/.gitignore git add config/.gitignore git commit 
+5
source share

Yes it is possible.

git update-index --skip-worktree FILENAME

or

git update-index --assume-unchanged FILENAME

where FILENAME will be config/database.yml for your case.

If you use the second command (suppose no change), the files will be returned after the git reset command.

+8
source share

If "database.yml" is added to your git repository before you specify it in the ignore file, I think you need to delete it:

 git rm config/database.yml git commit -a -m "Removed database.yml" 

Then add the database.yml file to your project, it will work fine.

+6
source share

Removing the .yml database is not a good idea if the application is intended to be downloaded and installed by other users. If you have inexperienced users who install your application, deleting the file looks like a step. Telling git to ignore the file after adding it with default values โ€‹โ€‹is the correct way in this case.

0
source share

All Articles