How do you deal with configuration files in source control?

前端 未结 19 2004
情书的邮戳
情书的邮戳 2020-11-27 13:00

Let\'s say you have a typical web app and with a file configuration.whatever. Every developer working on the project will have one version for their dev boxes, there will be

19条回答
  •  孤城傲影
    2020-11-27 13:23

    +1 on the template approach.

    But since this question has tag Git, the distributed alternative springs to mind, in which customizations are kept on a private testing branch:

    A---B---C---D---           <- mainline (public)
         \       \
          B'------D'---        <- testing (private)
    

    In this scheme, the mainline contains a generic, "template" config file requiring the minimal amount of adjustments to become functional.

    Now, developers/testers can tweak the config file to their heart's content, and only commit these changes locally on one a private testing branch (e.g. B' = B + customizations). Each time mainline advances, they effortlessly merge it into testing, which results in merge commits such as D' (= D + merged version of B's customizations).

    This scheme really shines when the "template" config file is updated: the changes from both sides get merged, and are extremely likely to result into conflicts (or test failures) if they are incompatible!

提交回复
热议问题