The project has a file super.config . It contains many different project settings. For example, configuration of interaction with a third-party service and logging level. Version Control System - git.
What is the problem: ')
This file should be under version control, as it contains “general” settings. Well, the file structure itself is valuable.
Each developer changes the level of logging to fit his needs and does not want these changes to fall into commits, and even more so in the integration repository.
General settings are periodically changed in this file, and the developer wants to receive them ( pull ) and publish ( commit )
Possible solutions:
Keep the source code of the application and its configuration separately. But life is a pain, and not always it can be done. The reasons for this are different: from technical to ( incompetent people ) administrative.
Scramble with loading configuration. For example, under version control, store default.super.config and exclude super.config . The application must first load the properties from default.super.config , and then, if there is one, from super.config . Moreover, the values ​​from the last overlap the values ​​from the default.
Just do not add changes to the local config in the index. Pros:
Simplicity.
If you need to commit changes in the config, then this is done fragmentarily ( git add -p ).
Minuses:
You can't do git add.
Constantly "looming" some changes. The developer analyzes them every time, checking whether everything is commited.
Switching ( checkout ) to a branch with a different config is possible only with the -m key or through the stash (the -f key kills changes in the working copy).
Pull configuration changes leads to an error. Before you get the changes, local will have to be removed on the shelf.
Exclude config from version control. It will not work. Only untracked files can be excluded from version control.
Convince git that the config file does not change. How to do it:
git update-index --assume-unchanged super.conf
Pros:
git add. will not add too much.
"Clean" status.
Minuses:
Git will not be able to switch to a branch with another config, to receive or commit changes to the config. At the same time, messages in the console can be misleading: git status writes “nothing to commit, working directory clean” , and git pull - “Your local changes to the following files would ...” . In order to resolve this situation, you will have to open your eyes with the git command using the git update-index - no-assume-unchanged super.conf command . And still, then have to use the shelf.
You can see what git closes its eyes with the git ls-files -v |grep -e "^ [hsmrck]" (no, well, it's still clear).
What would I do:
If the config changes extremely rarely, then --assume-unchanged looks like a suitable solution. Otherwise, I would simply not pay attention to the changes.
In general, it is necessary to store the settings separately.