分支:用于发布/开发的不同配置文件 [英] Branching: different config files for release/development

查看:110
本文介绍了分支:用于发布/开发的不同配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一个项目,我们正在使用git。我们有许多环境(dev,test,prod)。以前的团队基本上重新创建每个实例上的所有内容,使用相同的帐户,密码,sid等。唯一改变的是/ etc / hosts中的主机名映射。所以它会连接到不同的数据库服务器。



现在,这会产生一个问题,因为我不能,例如复制一个模式,以便开发人员可以运行一个使用与主开发服务器相同的数据库实例的实验。我基本上必须在另一个主机上创建一个新的数据库实例,并将/ etc / hosts更改为指向该新服务器。



虽然这是当前的工作设置,但我试图找到一种方法来维护每个实例的不同配置文件。即:不同版本的 applicationConfig.xml 取决于分支。我猜测有人可能会争辩说,将数据库凭证保存在回购中并不是一个好主意,但让我们暂时忽略这一点。



另一种可能的情况是可能的拥有不同版本的文件可能会被调试。假设我正在使用JavaScript记录器框架,并添加了我不希望随生产版本一起提供的调试代码。我不想在开发/测试时添加记录器的东西,然后在发布之前再次删除它。有人可能会忘记去做。



处理不同分支文件的不同版本的正确方法是什么?有没有办法让一个分支与master上的最新代码保持同步,但是有一些config / code文件被改变了?我不希望它自动保持同步,但我希望能够不能合并配置文件(或其中的一部分),而不会完全忽略它们(?)。例如:不要合并第6,7行(数据库用户名和密码),但要合并其他更改到文件。

听起来你应该阅读git属性。 查看本页底部的部分


如果您的项目中的某个分支已经分化或者是
专业化,但您希望能够合并它的变化,
,并且你想忽略某些文件。假设你有一个名为database.xml的数据库设置
文件,它在两个分支中是不同的,而你
想要在你的其他分支中合并而不会搞乱数据库
文件。



I've inherited a project and we are using git. We have a number of environments (dev, test, prod). The previous team basically recreated everything on each instance, using the same accounts, passwords, sid, etc. The only thing that changed was the hostname mappings in /etc/hosts. So that it would connect to a different database server.

Now, this creates a problem, because I can't, for example copy a schema so that a developer can run an experiment using the same database instance as the main development server. I basically have to create a new database instance on another host, and change /etc/hosts to point to that new server.

While this is currently a working setup, I'm trying to find a way to maintain different config files for each instance. ie: Different versions of applicationConfig.xml depending on the branch. I'm guessing one could argue that keeping database credential in the repo is not such a great idea, but lets just ignore that for a second.

Another situation that might warrant having a different version of a file could be debugging. Say I'm using a javascript logger framework, and I add debug code that I wouldn't want to ship with a production release. I don't want to have to add the logger stuff when developing/testing and then remove it again before releasing. One might forget to do it.

What's the proper way to deal with different "versions" of a file for different branches? Is there a way to have a branch that remains in sync with the latest code on master, but with a few config/code files changed? I don't expect it to remain in sync automatically, but I'd like to be able to not merge the config files (or parts of them), while not ignoring them completely (?). For example: don't merge lines 6,7 (db username and password), but do merge the other changes to the files.

解决方案

It sounds like you should read up on git attributes. Check out the section at the bottom of this page

This is helpful if a branch in your project has diverged or is specialized, but you want to be able to merge changes back in from it, and you want to ignore certain files. Say you have a database settings file called database.xml that is different in two branches, and you want to merge in your other branch without messing up the database file.

这篇关于分支:用于发布/开发的不同配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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