Git and Rails: ignore database.yml

Shyam picture Shyam · May 18, 2010 · Viewed 8.2k times · Source

I finally made a great step by abandoning SVN for Git and loving it. It must be somewhere, but I can't really find on how to do this, gitosis friendly.

I have my repo 'site' stored on a remote machine. I push my working copy and pull this data on a production machine. One mayor difference though is 'one' file: database.yml, which will never change on the production machine.

Is it possible (and if so, how), when the data is pulled from the repo, to "ignore" only this file? I am doing this manually at this point, but some elegance would be most appreciated.

Thanks.

Answer

Evgenii picture Evgenii · Feb 1, 2012

Yes, it is possible.

git update-index --skip-worktree FILENAME

or

git update-index --assume-unchanged FILENAME

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

If you use the second command (assume-unchanged), the files will revert after git reset command.