你如何处理源代码管理中的配置文件? [英] How do you deal with configuration files in source control?

查看:253
本文介绍了你如何处理源代码管理中的配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设你有一个典型的Web应用程序和一个文件配置。每个开发该项目的开发人员都会为他们的开发工具箱提供一个版本,将会有开发人员,产品和舞台版本。你如何在源代码控制中处理这个问题?不检查这个文件,用不同的名字检查它,或者做一些奇怪的事情? 解决方案

我在做什么过去是有一个默认配置文件签入到源代码管理。然后,每个开发人员都有自己的覆盖配置文件,该文件从源代码管理中排除。应用程序首先加载默认值,然后如果覆盖文件存在,加载它并使用覆盖的任何设置,优先于默认文件。



通常,覆盖文件越小越好,但对于具有非标准环境的开发人员,它总是可以包含更多设置。


Let's say you have a typical web app and with a file configuration.whatever. Every developer working on the project will have one version for their dev boxes, there will be a dev, prod and stage versions. How do you deal with this in source control? Not check in this file at all, check it with different names or do something fancy altogether?

解决方案

What I've done in the past is to have a default config file which is checked in to source control. Then, each developer has their own override config file which is excluded from source control. The app first loads the default, and then if the override file is present, loads that and uses any settings from the override in preference to the default file.

In general, the smaller the override file the better, but it can always contain more settings for a developer with a very non-standard environment.

这篇关于你如何处理源代码管理中的配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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