peoro
peoro

Reputation: 26060

Configuration file with untrackable parts

I've got a configuration file containing some configuration important for the whole project (ie: anybody who clones the repository should have this same conf), and some local configuration (anybody who clones the repository could need to customize something in this file, and I don't want to track local customization).

This file is unique: I cannot configure the software to use multiple files, and it doesn't support any kind of include directive.

Is there any way to handle this scenario with Git?


I could use git-add -p or -i to only stage part of this file, but it's not a good solution: it's too error prone, requires quite some work and git-status will always display this configuration file as locally modified.

Maybe I could use some git hooks?

Upvotes: 2

Views: 162

Answers (2)

Janne
Janne

Reputation: 1009

Have a "config.global" and a "config.local" file for your checked in global config and the local user-specific parts. Make a wrapper script for the application (how, exactly, will depend on the OS of course). Have the script first check for modification time of the global, local and "real" config file. If either partial file is newer, concatenate them into the real config. Then start the application proper.

Upvotes: 1

BillRobertson42
BillRobertson42

Reputation: 12883

There really is no way to track part of a file in git that I know of.

You could modify the code to load the main file, and then one customized for the environment that overrides the defaults. Developers can keep their own custom version, and you might also use the custom one for differences in test/dev/prod etc...

Upvotes: 0

Related Questions