Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 578
Alessandro De Simone Avatar asked Aug 11 '26 16:08

Alessandro De Simone


2 Answers

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.

like image 123
robertokl Avatar answered Aug 13 '26 09:08

robertokl


(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.

like image 22
VonC Avatar answered Aug 13 '26 09:08

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!