Need GIT workflow suggestion

久未见 提交于 2019-11-30 10:34:59
VonC

It a classic "config file" situation (even if your files are not exactly config file).

The usual solution is to:

  • put only variable names in your code
  • extract the values specific to each environment in their own files
  • version a script able to generate the actual code (the one in which variable names have been replaced with their values depending on the current environment)
  • set a filter driver (see Git ProBook) to automate the variable substitution (meaning no "new files" are created: only the current code is modified on git checkout -- variable replaced by values --, and "cleaned" on git commit -- values replaced by variables, and values put back in a separate config file if they have been modified)

That way, you don't have necessarily to create separate branches just because you have separate values in some files.
No complex merges, copy between branches and so on.

Just:

yourCode1.code yourCode2.code ... yourCoden.code devValues.txt prodValues.txt scriptPutValuesInCode.sh scriptCleanCodeFromValues.sh 

and a filter "smudged clean"

*.code  filter=setOrCleanValues  git config --global filter.setOrCleanValues.smudge /path/to/scriptPutValuesInCode.sh git config --global filter.setOrCleanValues.clean /path/to/scriptCleanCodeFromValues.sh 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!