What is the best way to handle configuration files using git?

Say my application has configuration files in text format. They contain some confidential information that is required to test the application in my dev environment. I use different OSs to access and work on my projects (win, mac, ...).

I do not want any information in the configuration files to fall into my public git repository. In the best case, I want sensitive information to be replaced with placeholders and upload configuration files to the repository in order to track their structure.


How do you approach the problem?

The hook itself will not be a big problem for me to write. I'm more interested in how to tie it all together, a possible directory structure, etc. I am completely new to git.

+3
source share
1 answer

In the world of Django, there is an agreement in which you can use - there is a standard file settings.pythat imports the module local_settingsat the end, if there is one available.

You have all your sensitive materials in this local_settings.pyfile and add it to .gitignoreso that it does not fall into the repository. In this way, people find out that they can add their own settings to local_settings.

For example,

settings.py:

DATABASE_USERNAME = 'your username here'
DATABASE_PASSWORD = 'your password here'

local_settings.py:

DATABASE_USERNAME = 'my top secret username'
DATABASE_PASSWORD = 'my top secret password'

The best part is that everything that you define in settings.pywill be overridden by the same name in local_settings.py.

+3
source

Source: https://habr.com/ru/post/1702519/


All Articles