I would recommend to version only template of those config files, instead of the actual config files with their valued.
You could consider a content filter driver (using .gitattributes
declaration) in order to generate the actual files.
The idea is to manage those config files in version, but with template placeholders in place of the actual (sensitive) values.
The generated files remains ignored (by the .gitignore
)
- the smudge part could replace the template content with the actual value (on checkout)
- the clean part could restore the template (on commit)

(image from "Customizing Git - Git Attributes", from "Pro Git book")
The main idea is: if values are depending on the environment, the smudge script would replace the placeholder values with actual values depending on the environment, values fetched possible from outside the repo (this is especially true for production values).