git-flow完成发布-选择性合并 [英] git-flow finish release - selective merge

查看:77
本文介绍了git-flow完成发布-选择性合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近开始在公司中使用git-flow,并且遇到了以下问题:

We've recently started using git-flow in our company, and we've came across the following issue:

我们有一个DEV_MODE布尔值,用于控制应用程序中的登录级别,我们希望develop分支始终具有DEV_MODE=true.
但是,发布版本时,我们将DEV_MODE更改为false.

We have a DEV_MODE boolean that controls the level of logging in the app, we want the develop branch to always have DEV_MODE=true.
However, when releasing a version we change the DEV_MODE to false.

当我在git-flow中完成发布时,它将把DEV_MODE=false合并到dev分支中.

When I do finish-release in git-flow, it'll merge the DEV_MODE=false into the develop branch.

我有一个钩子可以用来防止这种情况发生,或者也许是一种告诉git如何合并发行分支中的文件进行开发的方法?

I there a hook I can use to prevent this, or maybe a way to tell git how to merge files from release branches to develop?

推荐答案

您可以通过对文件模板"中的占位符值进行版本控制来完全避免合并问题:

You can avoid the merge issue entirely by versionning a file "template", with a placeholder value in it:

DEV_MODE=@devmode@

然后,您可以声明内容过滤器驱动程序(在取决于当前签出的分支机构.

You can then declare a content filter driver (in a .gitattributes file) in order to automatically generate the right content for that file on checkout, depending on the branch currently checked out.

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

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

smudge脚本可以使用它来检测当前分支:

The smudge script can use this to detect the current branch:

#!/bin/sh
branch=$(git rev-parse --symbolic --abbrev-ref HEAD)

这篇关于git-flow完成发布-选择性合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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