问题描述
假设您有一个典型的网络应用程序和一个文件配置.无论如何.每个参与该项目的开发人员都将有一个用于他们的开发箱的版本,将有一个开发、生产和阶段版本.你如何在源代码管理中处理这个问题?根本不签入这个文件,用不同的名字来检查它或者干脆做些花哨的事情?
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.
这篇关于你如何处理源代码控制中的配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!