I have to make local changes to my project files in order to get it to run in a different environment. Twice now I accidentally checked those changes in (and messed up ever
Solution depends on how many changes you're talking about. I work with .net websites so for most sites I'd have a different config file for each environment. e.g:
web.deploy.config
web.dev.config
These would all be under source control. Then copy the one of these files to web.config on the server it's running on (leaving this file out of source control). Works for me.