Search code examples
gitmacosgitosis

Git and Rails: ignore database.yml


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.


Solution

  • My advice: don't even put it into git. Make a database.yml.skel or something like that, so that a user can model their own database.yml, with that in mind as a sample. However, in my opinion conf files do not belong in version control - exactly for the reason you mention.

    Ignoring is very easy: in fact, there are several ways to do it. The correct for this one is .gitignore file; another one is .git/info/excludes. See this answer for details.

    So, off the top of my head:

    echo database.yml >> config/.gitignore
    git add config/.gitignore
    git commit