使用Git进行分支或针对不同环境的其他解决方案 [英] branching or other solution for different environments, using Git

查看:286
本文介绍了使用Git进行分支或针对不同环境的其他解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个环境.我自己的,我在哪里工作,以及客户的站点. 我是唯一要接触代码的人,但是我想完全使用Git.

I have two environments. My own, where I work, and the customer's site. I'm mostly the only one who is going to touch the code, but I want to use Git altogether.

在我的环境中,我需要更改C#项目的引用.

In my environment I need to change a reference for the C# project.

因此,大多数时候,我在我的环境中为代码和项目做很多好事,并拥有错误的"引用. 除了参考更改外,所有这些好东西还应考虑到客户的环境.

So, most of the time I'm with my environment doing a lot of good stuff to the code and the project, and having the "wrong" reference. All this good stuff should go also to the customer's environment, except of the reference change.

我可以通过分支或其他方式在Git中实现此目标吗? 在这里专门询问有关Git/分支的问题时,我看到我可以使用条件引用(

Any way I can achieve this with branching or otherwise in Git? While asking here specifically about Git/branching, I see I can use conditional references (How to reference different version of dll with MSBuild). But I'm still very curious.

有很多变通办法,例如避免提交参考更改. 但是我有一种感觉,当有人指出方向时,我会说:啊,我怎么没想到!".

There are plenty workarounds like avoiding committing the reference change. But I have a feeling that when someone points out to the direction I'll say "Ah, how didn't I think of it!".

非常感谢,奥伦.

推荐答案

根据从一个环境到另一个环境所做的更改的扩展范围,您可以考虑在需要更改的文件中使用占位符值.命令,在git checkout上,用正确的值替换那些占位符.

Depending on the extend of the changes you need to do from one environment to the other, you could consider using placeholder value in the files that need to change, in order, on git checkout, to replace those placeholder with the right value.

这是通过内容过滤器驱动程序完成的/a/2316728/6309> .gitattributes文件,并使用涂抹脚本.

This is done with a content filter driver declared in a .gitattributes file, and using the smudge script.

("自定义Git-Git属性",来自" Pro Git书 )

(image shown in "Customizing Git - Git Attributes", from "Pro Git book")

这篇关于使用Git进行分支或针对不同环境的其他解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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