Git custom merge to handle configuration files -


so searching way handle configurations file in git projet. read articles subject of them suggesting second, local-only file. , doesn't feel right me.

so messed around of git commands find way achieve things way.

a way found possible may :

files

the config example simple key : value list inside file.

the local state lastest pulled version of template :

1 : 1 2 : 2 3 : 3 

the remote state version on repository :

1 : 1 : 2 3 : 3 4 : 4 

on file have 1 new field : 4 , modified field a.

finally working state configuration file used application. copy of local file modified secret values running application. version should not pushed repository.

1 : secret1 2 : secret2 3 : secret3 

flow

here workflow thought :

on pull/checkout :

  • backup working file separate file prevent being rewritten;
  • do merge on local , remote last configuration template;
  • somewhat merge local , saved_working.

the last merge should provide user display new field add, long not overriding existing fields values.

an example of such operation may :

1st merge :

-    2 : 2 +    : 2 +    4 : 4 

2nd merge :

1 : secret1 -    2 : secret2 +    : 2 3 : secret3 +    4 : 4 

and now, before being able use application again, see lines changes.

what think ?

i think application should able read many configuration files, , default configuration file should stored in repository; example:

  1. read /path/to/the/app/default.conf
  2. read system-wide /etc/application.conf
  3. read user configuration (ie: ~/.config/application.conf), if in same directory application, use .gitignore

some projects (like ansible vault) store encrypted version of configuration file, solution too.

would work setup?

another suggestion separate branch cherry-pick code or configuration, depending preferences.

edit: precisions cherry picking.

this suggestion, it's toughs merging, except choose commits want "remote".

on machine, working in local branch:

  1. git fetch
  2. either git merge master or git cherry-pick commits want

nothing ground-breaking, i'm not sure if expect operation automated or manual.


Comments