什么是维护“服务器的版本”的正确方式, - 只有配置文件更改,在Git? [英] What is the right way to maintain a "version for the server" - with only config files changed, in Git?

查看:114
本文介绍了什么是维护“服务器的版本”的正确方式, - 只有配置文件更改,在Git?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有时使用Codeigniter,在我在本地网站上完成开发后,我需要将文件迁移到服务器。需要更改 / config / 文件夹中的所有文件以匹配服务器设置。为这些更改提交一个完整的提交是不正确的,我只是让Git完全忽略这些文件,或者有一种方法来跟踪这些更改并在适当的时候使用Git?


<您可以保留版本:




  • 两个值配置文件,每个环境都有正确的值

  • 一个模板配置文件,其中包含值占位符(例如 @@ PORT_NUMBER @@

  • 一个能够根据当前环境生成实际配置文件的脚本

  • a 更多关于git内容过滤器驱动程序的限制)。


    I sometimes work with Codeigniter, and after I'm done developing on the local site, I need to migrate the files to the server. All the files in the /config/ folder need to be changed to match the Server settings. It's not right to make an entire commit for these changes, do I simply make Git ignore these files altogether, or is there a way to track these changes and apply them with Git at the right moment?

    解决方案

    You could keep versioned:

    • two "value config files", with the right values for each environment
    • a template config file, with value placeholder in it (for instance, @@PORT_NUMBER@@)
    • a script able to generate the actual config file depending on the current environment
    • a content filter driver which, on checkout, will trigger the script in order to generate the right config file.

    Note: that supposes your template config file has a recognizable content (the filter doesn't have a name or path of the file). See "Git equivalent of subversion's $URL$ keyword expansion" for more on the limitation of git content filter driver).

    这篇关于什么是维护“服务器的版本”的正确方式, - 只有配置文件更改,在Git?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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