Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you deal with configuration files in source control?

Let's say you have a typical web app and with a file configuration.whatever. Every developer working on the project will have one version for their dev boxes, there will be a dev, prod and stage versions. How do you deal with this in source control? Not check in this file at all, check it with different names or do something fancy altogether?

like image 880
deadprogrammer Avatar asked Aug 08 '08 14:08

deadprogrammer


People also ask

What is a configuration source file?

A configuration file, often shortened to config file, defines the parameters, options, settings and preferences applied to operating systems (OSes), infrastructure devices and applications in an IT context. Software and hardware devices can be profoundly complex, supporting myriad options and parameters.

What do you do with config files?

Configuration files can be used by users to change settings without the need to recompile applications, programs or operating systems.

What is configuration file management?

Centralized configuration file management enables you to maintain multiple versions of your device configuration files in Junos Space Platform. This helps you recover device configuration files in case of a system failure and maintain consistent configuration across multiple devices.

Should I add project configuration files to Git?

Show activity on this post. The short answer to your question is Yes. I wouldn't hesitate to recommend Git (or any other version control software) to keep track of configuration files.


2 Answers

What I've done in the past is to have a default config file which is checked in to source control. Then, each developer has their own override config file which is excluded from source control. The app first loads the default, and then if the override file is present, loads that and uses any settings from the override in preference to the default file.

In general, the smaller the override file the better, but it can always contain more settings for a developer with a very non-standard environment.

like image 64
yukondude Avatar answered Sep 16 '22 22:09

yukondude


Configuration is code, and you should version it. We base our configuration files on usernames; in both UNIX/Mac and Windows you can access the user's login name, and as long as these are unique to the project, you are fine. You can even override this in the environment, but you should version control everything.

This also allows you to examine others' configurations, which can help diagnose build and platform issues.

like image 33
davetron5000 Avatar answered Sep 20 '22 22:09

davetron5000