2

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?

nwinkler
  • 52,665
  • 21
  • 154
  • 168
marmor
  • 27,641
  • 11
  • 107
  • 150

1 Answers1

5

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.

http://git-scm.com/book/en/v2/book/08-customizing-git/images/smudge.png

(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)
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks, sounds exactly what I want. quick question - will the 'git config --global' command get shared between my fellow workers or will it be only for me? – marmor Feb 26 '15 at 16:01
  • @marmor a git config (global or otherwise) is always local (local to the repo, local to the user or local to the machine). It is never shared. – VonC Feb 26 '15 at 16:02