A good way to solve this is to use web.config transformations
When you publish your site you choose whether you want it to be Debug/Release/Custom - this then chooses whatever you have defined in the corresponding web.config and injects it into the version it creates.
For example, you could choose to have customErrors off on local, but then on for release. It's also useful for defining different database connections etc.
QUBA – sitefinity specialists