DEV Community

Discussion on: Don't commit that file!

Collapse
 
grmnsort profile image
German Rodriguez Ortiz • Edited

Hi,

At work, we had the same problem, but we ended trying a different approach.
What we do is having a .dist version of every file that we want to keep tracked "as is" but don´t want to track changes that people do over them, and in the .gitgnore we simply ignore the "non .dist files". So in the end we have a tracked file structure like this:

├── app
│   ├── config
│   │   ├── some-general-config.yml
│   |   ├── local-parameters.yml.dist
│   |   ├── variable-config.yml.dist
|-- .gitignore

and in the .gitignore we just add:

/app/config/local-parameters.yml
/app/config/variable-config.yml

That way everyone (including our testing and production environments) get a copy of the config files that provide the exact info to each app instance that we have. Right now when you clone an instance, you would have to manually create the "real" copies of the config files and edit them, but we´re making a script that we intend to run on our composer install phase that will add a stage that does this automatically.

Collapse
 
bronzehedwick profile image
Chris DeLuca

Hey Germán, that's a nice solution. Unfortunately we can't tell our app to recognize a different config file, but you gave me an alternate idea. Perhaps there's a path in YAML where we have the regular config file checked in, then have a local config file that overrides any values set in the general that's in .gitignore. The YAML in the general file would be something like:

source: my-local-config.yml