【问题标题】:How to not merge webconfig file every merge event?如何不合并每个合并事件的 Web 配置文件?
【发布时间】:2019-07-19 08:36:42
【问题描述】:

我们的开发团队在测试或开发阶段使用不同的 webconfig 设置,如连接字符串等,有时会意外推送这些更改,这会导致大问题。推送后,Jenkins 应用更改,我们浪费了大量时间来查找错误。我们通过 Bitbucket 使用 git 控制系统。如何预防这些问题?

我也尝试过像这样 gitattribute 文件,但之后,新的分支推送仍在合并它。

# Source https://help.github.com/articles/dealing-with-line-endings
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto

# Explicitly declare text files we want to always be normalized and 
converted 
# to native line endings on checkout.
---is it necessary to specify?

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.config binary
*.jpg binary
*.ico binary

core.autocrlf=true

【问题讨论】:

标签: c# asp.net git bitbucket


【解决方案1】:

有两个主要的解决方案系列:

  1. 拥有一个配置文件并告诉 git 不要跟踪对该文件的(本地)修改。

    git update-index --assume-unchanged

  2. 更优雅的解决方案是只在 git 中跟踪 connectionstring_template.conf(包含生产代码)。 connectionstring.conf 文件已添加到您的 .gitignore。因此,当您第一次在机器上部署代码时,您只需复制并重命名模板文件,并根据需要对其进行调整。请注意,git 不会跟踪配置文件,因此您无法将测试配置传播到生产环境。如果您想从模板文件自动更新生产环境中的所有 conf 文件,一个简单的脚本就可以完成这项工作(手动启动或使用 git hooks)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-24
    • 1970-01-01
    • 2012-03-06
    • 2021-06-10
    • 1970-01-01
    • 2022-10-07
    • 1970-01-01
    相关资源
    最近更新 更多