Query to compare code between Environment

I was wondering if anyone have figure out what is the best way to push the code across the environmet Dev/UAT/PROD. I know we can point to the UAT in DEV environment as Data Source and then possibly use some system services to compare the code to see what is different between the two environment. Currently there is no way to check the code we pushing in to QA, but what exactly the changes are compare to UAT or even PROD!