views:

90

answers:

5
+1  Q: 

Files in gitignore

I have a repository with a rails app in the production Server.

In the repo there is the .gitignore file:

...
    config/database.yaml 
...

Every developing client have a cloned repo with different config/database.yaml.

My problem is this:

database.yaml is in .gitignore, then when I run git clone (on the server) the database.yaml will not be created, but I need it.

I thought than I am doing wrong something. Can you see where is my mistake ?

thank you, Alessandro

+10  A: 

In my projects, I usually make a copy of a usable database config in a database.example.yml, then when someone clones the projects, copy the database.example.yml to database.yml and make the needed changes.

robertokl
A: 

Hi,

All these database.yaml files have something in common: you can commit a base configuration, and let all your developing clients maintain a fork of it in their own branches with appropriate settings filled in; they can rebase on top of the base configuration in the master branch whenever it gets updated.

Ramkumar Ramachandra
A: 

aleds - it's generally a bad idea to have your database.yml in a repository which is why you see it in .gitignore. robertokl is right about providing a template file.

Tony
+1  A: 

keep a template like database.example.yml as robertokl suggests

when you deploy your application to production server you should be using something like capistrano and part of your capistrano recipe(script) will be to rename that file or to place the correct database.yml file in the config dir

ErsatzRyan
+2  A: 

(here is a copy of my original answer to your first question)

You don't version the right file.

You should version:

  • a database.yaml.template
  • 2 files (one for server values, and one for generic client values)
  • 1 script able to build database.yaml on the checkout

That script would be called by the smudge step of a filter driver.

alt text

The resulting database.yaml would be "private" (never versioned/pushed or pulled), and can be modified at will.

VonC