git-flow finish release - selective merge

随声附和 提交于 2019-12-22 18:09:49

问题


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

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.

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

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?


回答1:


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.

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

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

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


来源:https://stackoverflow.com/questions/28739242/git-flow-finish-release-selective-merge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!