使用不同的配置文件为开发和测试分支设置Git [英] Setting up Git for Development and Test Branch with different config files

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

问题描述

我们有一个WordPress安装,它有一个Live,Test,Dev的不同配置文件。我知道如何让Git忽略 wp-config.php 文件,但我想要在每个分支中使用不同的WP-config文件。因此,当开发人员切换到Dev时,它将使用Dev的数据库设置。我的过程是:


  • 提交


  • 创建新的Dev Branch


  • 按照此过程,这意味着我不能再使用开发人员配置详细信息更新开发分支,供其他用户使用。



    任何人都可以建议如何做到这一点吗?

    解决方案

    你想在你的分支中有不同的wp-config文件,但是当你将一个分支合并到master中时,它们不应该被合并。



    我能想到三种解决方案到你的问题:


    1. 你可以把它们放到你的分支中,而不是把它们合并到master中,而是采用cherry-picking。

    2. 您可以将它们放入分支并提交更改ect文件。 您可以将文件完全保留在回购库中(通过.gitignore)并使用post-checkout钩子进行复制/每次结账后将正确的文件链接到工作目录中。 前两个有优势,文件在回购站,但合并/纠正变得丑陋。



      第二个是有点壳攻击,每个检查回购的人都必须把钩子在他的.git / hooks目录中。此外,您可能需要针对Windows和Linux系统使用不同的脚本。



      详细阅读:
      Git条件文件


      We have a WordPress install that has a different config file for Live, Test, Dev. I understand how to get Git to ignore the wp-config.php file, but I want a different WP-config file in each of the branches. So that when a developer switches to Dev, it will use the database settings for Dev.

      My process, is:

      1. put live site into master.

      2. add .gitgnore

      3. commit

      4. create new Dev Branch

      Following this procedure, it means that I can no longer update the Dev branch with the Dev Config Details for other users to use.

      Can anyone advise on how to do this please?

      解决方案

      I understand, that you want to have different wp-config files in your branches, but they should not be merged, when you merge a branch into master.

      I can think of three solutions to your problem:

      1. You could put them into your branches and not merge them into master, but do cherry-picking instead.

      2. You could put them into your branches and commit the correct file after every merge.

      3. You could keep the files out of your repo completely (via .gitignore) and use the "post-checkout" hook to copy/link the correct file into the working-directory after every checkout.

      The first two have the advantage, that your files are in the repo, but merging/correcting gets ugly.

      The second is a bit of shell-hacking and everyone that has checked out the repo has to put the hook in his .git/hooks directory. Additionally, you probably need different scripts for windows and linux systems.

      Further reading: Git conditional files

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

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