Microsoft suggests that you use
web.config transformations for deployment changes to your web.config.
But seening as you're using Git, I'm speculating that you don't deploy using the MS deployment method.
If you're just copying the files from a repository, I'm afraid you'll always have some manual commenting/uncommenting to do in the web.config. Of course you could write your own transformation (or find 'n replace') job.
But best practices stipulate that you have each applictation running in it's own app pool. If you each app pool is running under it's own user (such as the
Application Pool Identities), they you don't really have a problem with deployment looking at the incorrect database, no matter what server they are on. ('cause you'll get a big, fat, "this db can't be read by this user" error if you try to run without correcting the connectionstrings)
i.e: Your staging and prod may be on the same db server, but they shouldn't be using the same database, so just make a Kentico user for each. You can be
primitive old Skool about it and have to comment or change the connectionstring settings manually, or you could work some sort of transformation process into your deployment to make things a bit smoother/automated.
Lance