使用GIT时,从Build Box(VSTS)中隔离配置(Isolate Configs from Build Box (VSTS) when working with GIT)

编程入门 行业动态 更新时间:2024-10-28 04:25:45
使用GIT时,从Build Box(VSTS)中隔离配置(Isolate Configs from Build Box (VSTS) when working with GIT)

我们正在Visual Studio Team Services(VSTS)中实现一个环境。 我们有一个与VSTS绑定的Git Repo

问题是如何将Config文件分开,以便它们在本地环境中保留其唯一值? 但是没有上传Configs VSTS就无法在其环境中构建。

我们不希望VSTS中的相同配置设置始终与本地环境同步,也不希望将本地配置推送到主服务器。 显然,我们可以排除Push,但问题是如何以允许它成功构建而不需要将配置文件上传到Repo的方式配置VSTS?

回顾这篇文章,我不确定是否需要基于回购的配置: 如何处理VSTS版本管理中的多个配置? 是的,我们最终会有多个配置来允许Staging和Production版本。

We are implementing an environment in Visual Studio Team Services (VSTS). We have a Git Repo tied to VSTS

The problem is how to keep the Config files separate so they retain their unique values in their local environments? But without uploading Configs VSTS fails to Build within it's environment.

We don't want the same config settings that are in VSTS to always Sync to Local Environments nor do we want to Push our local configs to the Master. Obviously, we can Exclude on Push but the question is how to configure VSTS in a manner that allows it to Build successfully without requiring config files to be uploaded to the Repo?

Reviewing this post, I'm not sure whether or not Repo based configs are required: How to handle multiple configurations in VSTS Release management? And yes we will eventually have multiple configs to allow Staging and Production releases.

最满意答案

直接答案是否定的。通常git只跟踪项目的源代码,而VSTS通常可以在没有配置文件的情况下成功构建。 我不确定你的项目是什么,所以我们可以处理你需要将配置文件推送到VSTS而且在git pull时不影响本地设置的情况(假设配置文件的名称是project.config ):

选项1:

如果在VSTS中构建时可以重命名project.config ,则可以将project.config用于本地环境,将projectRemote.config用于.gitignore的远程repo:gitnore project.config ,并将projectRemote.config文件创建为推到远程。

选项2:

从远程拉取更改时保留本地project.config版本。 您可以保留本地版本:

touch .gitattributes echo 'project.config merge=ours' >> .gitattributes git config --global merge.ours.driver true

注意:合并策略似乎仅在拉不快进时才有效。

The direct answer is No. Usually git only track source code for projects, and VSTS usually can build successful without config files. I’m not sure what’s your project is, so we can deal with the situation for that you need to push the config file to VSTS but also do not effect local settings when git pull (assume the name of the config file is project.config):

Option 1:

If it’s ok for you to rename project.config when you build in VSTS, you can use project.config for your local environments and projectRemote.config for the remote repo: gitnore project.config in .gitignore, and create projectRemote.config file to push to remote.

Option 2:

Keep local project.config version when pull changes from remote. You can keep local versions by:

touch .gitattributes echo 'project.config merge=ours' >> .gitattributes git config --global merge.ours.driver true

Note: the merge strategies seems only works when the pull is not fast forward.

更多推荐

本文发布于:2023-08-04 23:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1423156.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Box   Build   GIT   VSTS   working

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!