3

I am creating a few small experiments / examples which I am open sourcing on git hub.

How have people dealt with user specific config/set-up vars in the past?

I would ideally like to commit the exact same code that I myself am using, but without including my URL's or app id / secrets etc.

I have thought that perhaps I could do it in one of the following ways, but is there a standard or recommended way of doing this?

baseURL = include myConfig.txt;

or

baseURL = "Enter Your URL Here";
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Trevor Boyle
  • 1,025
  • 7
  • 15

4 Answers4

3

You could have the very simplest config options as environment variables.

You could have a small config object, which holds dummy values.

You could add a config.ini.sample file.

olleolleolle
  • 1,918
  • 16
  • 20
2

For this kind of configuration (file with "secret private" content, private as "visible only within my working tree, but never versioned in the Git repo), I always recommend a custom filter driver (See also Pro Git book for the principle):

filter driver

  • a template of your setting file (settings.template, with baseURL),
  • a script able to generate a proper setting file settings based on local values found in your working tree (like an encrypted file with the secret value ready to be decoded and put in the setting file by the smudge script)
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

Me personally I would use a special commit to my own GIT tree which includes my own specialities. So they are separated from the rest of the history. Whenever I push my changes to the public tree, that commit would be omitted.

I don't know however how to ensure not to accidentally push the commit. But there ought to be some way.

ypnos
  • 50,202
  • 14
  • 95
  • 141
0

You can read configuration values from a file, for example config.txt, and commit config.txt.example with helpful comments, default values where applicable and dummy values in other places, so users can just copy that to config.txt and change the needed values.

Aleksi Torhamo
  • 6,452
  • 2
  • 34
  • 44