Managing project config files in repository

我是研究僧i 提交于 2020-05-18 18:52:12

问题


I have some questions about managing config files in git repo.

Question 1: Suppose we have .env in master that looks like this (variables just declared but not defined!):

XXX_CLIENT_ID=
XXX_SECRET=

Then someone pull master, create local branch, change .env, do some commits and then wants merge to master. How can master branch omits changing in .env file during merge? Is git update-index --assume-unchanged solves this or may be we can handle it better?

Question 2: OK, let's look situation when we want share config in our team, for example .dev.env. Like in Question 1 in master we have file similar like .env without values but we want share it in team and it should be secret for public because master still public. It looks like git-secret do this job but I want hear what are you using today for solving this problem.

Any good idea or best practices how you manage it in your team?


回答1:


For question 1: A good practice is to separate code and configuration. I.e in the repository that holds your code you have a .env.sample file that specifies what config variables the application expects to be set (possibly with default values). People cloning or branching out from master locally can then specify their property values in a .env file that is added to .gitignore and thus not impacting the git tree. When the application is tested locally by the developer it uses the configuration in the .env, which is specific to the environment of the developer.

This way you can keep a .env.sample file in master indicating to the public what config is needed, but cloners need to specify their own .env for their local environment

A developer only edits the .env.sample file if config is added/removed (which is information that needs to be merged back to master)



来源:https://stackoverflow.com/questions/40548141/managing-project-config-files-in-repository

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