处理项目配置文件的最简单方法是什么? [英] What's the easiest way to deal with project configuration files?

查看:68
本文介绍了处理项目配置文件的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在任何项目中至少有一个配置文件是很常见的。每次我与 git 共享项目时,我遇到了同样的问题:


  • 敏感信息(每个开发人员都有不同的DB密码等)
  • 任务特定信息(当开发人员在某些需要更改某些设置的任务上工作时)
  • ul>

    显然,configs必须以某种方式被忽略,以防止开发人员特定的数据泛滥主存储库。现在有几种方法可以使用,每种都有一些缺陷:


    • .gitignore 配置文件

      • 最基本的方式

      • 当开发人员克隆repo时,配置文件丢失并且必须找出哪里configs重新创建它们


    • 配置文件不会被忽略。它包含一些虚拟信息,并且每个开发人员或者将其解包并放到他的 .git / info / exclude 或者设置为 git update-index --assume-无变化... 到文件

      • 文件适用于克隆回购的任何人

      • 它包含高级当人们偶然提交配置文件时,可能会混淆第一次使用git的人们的技术,它不会允许人们拉/取(如排除不工作与 .gitignore
      • 相同的方式

      • 分发带有后缀的配置文件,例如, _original ,同时在 .gitignore 中有真实文件。每个开发人员然后将文件重命名为真实姓名

        • 文件适用于克隆repo的任何人

        • 必须在整个应用程序中搜索所有配置并重命名它们



          $ b

          是否有其他可能更好的方法来处理这个问题?我怀疑我至少缺少了一些插件。

          自动实现选项3的方式,详见当你在项目中有密钥时,如何推送到GitHub?





          smudge 脚本将在结帐时:


          • 配置文件修改

          • 获取所需的信息(最好保存在<任何Git仓库之外),并将模板值替换为实际值。


          从那里开发者可以对这些配置文件进行任何形式的修改。

          它赢得了'这很重要,因为在提交时, clean 脚本会将该文件的内容恢复为其原始(模板)值。没有意外推到那里。

          It's very common to have at least one configuration file in any project. Every time I share project with git, I have the same problem with:

          • sensitive information (each developer have different DB passwords etc)
          • task specific information (when developer works on certain task where one needs to change some settings)

          Obviously, configs have to be ignored somehow to prevent developer specific data to flood main repository. Now there are several ways I used to use, each with some flaws:

          • .gitignore the config files
            • the most basic way
            • when developer clones repo, config file is missing and one has to find out where configs were recreate them
          • config file isn't ignored. It contains some dummy info and each developer either untracks and puts it to his .git/info/exclude or set git update-index --assume-unchanged ... to the file
            • files are available for anyone who clones repo
            • it contains advanced techniques which could confuse people that work with git for the first time
            • when someone commits config files by accident, it won't allow people to pull/fetch (as excludes don't work the same way as .gitignore)
          • distribute config files suffixed with, for example, _original while having the real files in .gitignore. Each developer then renames files to real names
            • files are available for anyone who clones repo
            • one has to search for all configs throughout application and rename them

          Are there any other, possibly, better ways to handle this? I suspect I'm missing something, some plugin at least.

          解决方案

          Filter drivers are the "automatic" way of implementing option 3, as detailed in "when you have secret key in your project, how can pushing to GitHub be possible?":

          The smudge script will, on checkout:

          • detect the right config files to modify
          • fetch the information needed (best kept outside any Git repo) and will replace the template values by the actual one.

          From there the developers can make any kind of modification they want to those config files.
          It won't matter, because the clean script will, on commit, restore the content of that file to its original (template) value. No accidental push there.

          这篇关于处理项目配置文件的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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