If the only difference between these three environments is just in settings for database servers or other configurations, you can still keep the code in same repository or branch for easy maintenance.
Instead, what you have to do is having a configuration file with different settings for different environments. For example, this practice or concept is used widely in Zend Framework project.
application.ini
; Production site configuration data
[production]
webhost = www.example.com
database.adapter = pdo_mysql
database.params.host = db.example.com
database.params.username = dbuser
database.params.password = secret
database.params.dbname = dbname
; Staging site configuration data inherits from production and
; overrides values as necessary
[staging : production]
database.params.host = dev.example.com
database.params.username = devuser
database.params.password = devsecret