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):
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)
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.
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.
发布评论
评论(4)
您可以将最简单的配置选项作为环境变量。
您可以有一个小型配置对象,其中包含虚拟值。
您可以添加config.ini.sample 文件。
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.
对于这种配置(包含“秘密私有”内容的文件,私有为“仅在我的工作树中可见,但从未在 Git 存储库中进行版本控制),我总是推荐 自定义过滤器驱动程序< /a> (原理另请参阅 Pro Git 书籍):
settings.template
,带有baseURL
),settings
的脚本(例如一个加密文件,其秘密值已准备好解码并放入setting
文件(由smudge
脚本生成)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):
settings.template
, withbaseURL
),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 thesetting
file by thesmudge
script)就我个人而言,我会使用对我自己的 GIT 树的特殊提交,其中包括我自己的专业知识。所以他们与历史的其他部分是分开的。
每当我将更改推送到公共树时,该提交都会被忽略。
但是我不知道如何确保不会意外推送提交。但应该有什么办法。
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.
您可以从文件中读取配置值,例如
config.txt
,并提交config.txt.example
以及有用的注释、适用的默认值和其他位置的虚拟值,因此用户只需将其复制到 config.txt 并更改所需的值即可。You can read configuration values from a file, for example
config.txt
, and commitconfig.txt.example
with helpful comments, default values where applicable and dummy values in other places, so users can just copy that toconfig.txt
and change the needed values.