I am working on a ecommerce based on MagentoCommerce. I use 3 environments: dev (on my local machine), staging and production (both on my dedicated server).
I'm running Magento on a Production server and a number of development and test domains.
The domain isn't hardcoded in any file - the domain is all in the database.
You have to change the secure base url and the unsecure base url when you move from server to server. Both of these are stored in the database and can be changed in the web based administration screens. When moving the database from one host to another, I use a script that does little but update these values. Here's the SQL you need to update these values:
update core_config_data
set value='http://whatever.com/'
where path='web/unsecure/base_url';
update core_config_data
set value='https://whatever.com/'
where path='web/secure/base_url';
You may also want to pay attention to the local.xml file where the database connection is configured. I'm sure that you'll want to have the different instances using different databases. In my configuration, I leave this file out of source control, and configure it just once for each instance.