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

查看:15
本文介绍了维护“服务器版本"的正确方法是什么?- 在 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天全站免登陆