You cannot just simply ignore changes in certain lines of the file, I'm afraid, so you are probably stuck with a separate configuration file. Below I have listed two typical ways to deal with this, and one a bit more exotic:
Have an example config file in git
Here you would save the config.sample file in git as an example, but the application would actually use the values โโin the config file, which is located in .gitignore . Then the application will throw an error if config not present. You must remember to change the values โโin the sample file when adding new configuration variables to your personal config file. In this case, itโs also good that your application checks that all the necessary configuration parameters are actually set, in case someone forgot to update their config file after making changes to the sample.
Has a default values โโfile in git
You save the config.defaults file in git, which, as far as possible, has reasonable default configuration values. Your first configuration of your applications is from config.defaults and then from config (which is located in .gitignore ) to possibly override any default values. With this method, as a rule, you would not make a mistake for the config not exist, so the application can work out of the box for people who did not bother to create a config .
Using a single configuration file with the -assume-immutable option
The third possibility, which I would not recommend personally in this case, would be to have one configuration file that was fixed in git, but use git update-index --assume-unchanged <FILE> to tell git to ignore the changes to him. (This is described later in this useful blog post .) This means that your local changes to the configuration file will not be submitted using git commit -a or displayed in git status .
Mark Longair Jan 20 2018-11-11T00: 00Z
source share