简体   繁体   English

Git工作流,devel和生产分支之间的差异忽略文件

[英]Git workflow, differences between devel and production branches on ignoring files

Say you have a develop branch and a master branch (master corresponding to production). 假设您有一个开发分支和一个分支(主要对应于生产)。 In the develop branch you might have a test folder, a scripts folder that you want to version control. 开发分支中,您可能有一个测试文件夹,一个您想要版本控制的脚本文件夹。

But every time you merge the develop branch with new changes to the master branch, you want to ignore scripts and tests , because master branch has exactly the same files that are in production (so that you could even automatically deploy the master branch in every merge). 但是每次将开发分支与分支的新更改合并时,您都希望忽略脚本测试 ,因为分支具有完全相同的生产文件(因此您甚至可以在每个合并中自动部署分支) )。

What's the best way to achieve that? 实现这一目标的最佳方法是什么? There should be a way to merge everything but some 'ignored' folders. 除了一些“被忽略”的文件夹,应该有一种方法来合并所有内容。

My question is a bit the same as this one . 我的问题与问题有点相同。 But I am surprised that is a not very popular question. 但我很惊讶这是一个不太受欢迎的问题。 I think this is a problem every developer that wants to be able to deploy automatically and is testing code will have to face 我认为这是一个问题,每个想要能够自动部署并且测试代码必须面对的开发人员

Create a .gitattributes file in master with 在master中创建一个.gitattributes文件

test merge=ours
scripts merge=ours

Note: I haven't actually been able to test this, because apparently .gitattributes with merge=ours does not work on msysgit . 注意:我实际上没有能够测试这个,因为显然.gitattributes with merge=ours 对msysgit不起作用

Another approach (from my old answer) is to use content filter driver declared in .gitattributes file. 另一种方法(来自我的旧答案)是使用.gitattributes文件中声明的内容过滤器驱动程序

过滤驱动程序

That would allow, on checkout, to generate the right script or config file, from the combination of template files and value files. 这将允许在结帐时从模板文件和值文件的组合生成正确的脚本或配置文件。

You would keep all value files (for master or dev) in the same directory: no need to merge them (they are different). 您可以将所有值文件(对于master或dev)保存在同一目录中:无需合并它们(它们是不同的)。
The common files are generated, so they are not versioned (not merged either) 生成公共文件,因此它们没有版本化(也没有合并)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM