I’d like to make a commit with git that contains a basic structure for connection strings in our .net application.
For instance we have a web.config that imports connectionStrings.config.
I’d like to commit an initial connectionStrings.config just so we dont have to keep adding one manually and it has the basic settings we need and we can just go an modify the various parts of the string (usually just the server name) and then ignore any changes to that file from that point forward.
Now I’ve tried adding it to .gitignore but from what I’ve read tracked files are exempt from the .gitignore I’ve also tried git update-index –assume-unchanged connectionStrings.config but that seems like a temporary fix as I’m still bugged about pending changes to the file when checking out another branch.
Is there any good way around this?
You could use a git attribute filter driver and version:
connectionStrings.basic.templatefilesmudgescript in charge of creating the actual (not versioned)connectionStrings.basicif it doesn’t exist, each time you checkout the repo (when the filter driver detects the content of that template file)connectionStrings.basic.template(in the case of modifications to that template file) in order to keep the template file immutable.See git attributes for an example.