You should not version a config.properties
(git rm
is right), and ignore it indeed.
That way, it won't pose any issue during merge.
It is easier to have three separate files, one per environment:
config.properties.dev
config.properties.uat
config.properties.prd
In each branch, you would then generate config.properties
, with the right value in it, from one of those files, depending on the current execution environment.
Since you have separate branches per environment, with the right file in it, you can have a generation script which will determine the name of the checked out branch with:
branch=$(git rev-parse --symbolic --abbrev-ref HEAD)
That means you could:
- version only a template file
config.properties.<env>
- version value files named after the branches:
config.properties.dev
, config.properties.uat
...: since they are different, there is no merge issue when merging or switching branches.
Finally, you would register (in a .gitattributes
declaration) a content filter driver.
(image from "Customizing Git - Git Attributes", from "Pro Git book")
The smudge
script, associated to the template file (package.json.tpl
), would generate (automatically, on git checkout
) the actual config.properties
file by looking values in the right config.properties.<env>
value file.
The generated actual config.properties
file remains ignored (by the .gitignore
).
See a complete example at "git smudge/clean filter between branches".
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…