Reputation: 8283
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?
Upvotes: 3
Views: 833
Reputation: 53462
How about putting the file in .gitignore and after cloning, run an init script (included in the repo) which will create the file? It could do other tasks as well, as it sounds like in your setup you might have other settings like that, too. If not now, maybe in the future.
Usually this kind of things are handled when building a runnable app from source code, but it sounds like your app doesn't need separate building process so you don't have that step. It's not optimal, but if it's just one command for this and any future needs, I don't think that's much.
There are a range of tools/scripting languages/helpers to do that, whatever would fit your environment/app best. Ant or similar would also be environment agnostic.
Upvotes: 0
Reputation: 1323175
You could use a git attribute filter driver and version:
connectionStrings.basic.template
filesmudge
script in charge of creating the actual (not versioned) connectionStrings.basic
if 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.
Upvotes: 1
Reputation: 1800
Why not just have something like connectionStrings.basic.config in git and just rename it for a new instance?
Upvotes: 1