如何实用地控制配置文件的版本? [英] How to version control config files pragmatically?

查看:93
本文介绍了如何实用地控制配置文件的版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们有一个包含敏感密码的配置文件。我想对整个项目进行版本控制,包括配置文件,但我不想共享密码。

如果这个配置文件很好,

Suppose we have a config file with sensitive passwords. I'd like to version control the whole project, including the config file as well, but I don't want to share my passwords.
That could be good, if this config file:

database_password=secret
foo=bar

成为

database_password=*
foo=bar

和其他vcs用户也可以自行设置密码。要忽略文件不是一个好方法,开发人员应该知道配置文件是否更改。

and the other users of the vcs could also set up the password on they own. To ignoring the file isn't a good approach, the developers should be aware, if the config file changes.

本地版本:

database_password=own_secret
foo=bar

vcs中的配置文件:

config file in vcs:

database_password=*
foo=bar

然后,配置文件突然更改:

Then suddenly, the config file changes:

database_password=*
foo=bar
baz=foo

每个开发人员都将使用本地版本:

And the local version would become for each developer:

database_password=own_secret
foo=bar
baz=foo

这是我的解。我该如何实现这种行为?您如何存储配置文件?有办法做到吗,还是我应该破解一些东西?

This is my solution. How could I achieve this behaviour? How do you store your config files? Is there a way to do that, or should I hack something?

推荐答案

您可以使用版本控制实际的配置文件来代替可以在版本控制中放入模板或默认文件,并在脚本中询问数据库信息和凭据以生成真实的配置文件,该文件将被排除在版本控制之外(即被版本控制忽略)。签出时,开发人员可以运行此脚本来获得工作环境。此脚本也可以在应用程序使用的任何安装过程中调用。

Instead of version-controlling the actual configuration file, you could put a template or defaults file in version control, and a script that would ask for DB information and credential to generate the real config file, which would be excluded from (i.e. ignored by) version control. On checkout, developers could run this script to get a working environment. This script could also be invoked as part of any installation process that your application uses.

查看我对类似问题的答案

这篇关于如何实用地控制配置文件的版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆