git-flow完成发布-选择性合并 [英] git-flow finish release - selective merge
问题描述
我们最近开始在公司中使用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屋!