I can't wrap my head around which problem this solves. The wp-config.php file should be unique for each site. You shouldn't be managing it under version control. And why do I need the database credentials for the live site on your testing server? Or your local development machine? If I break into your testing server then I would also have the necessary credentials for your live server now.

If you really want to have some settings keep them in a separate file in the root of your WordPress install and include it in wp-config.php and then version control that file.

Pro tip: If you need to enable WP_DEBUG temporarily you can set-up a simple conditional in wp-config.php

<?php
if( isset($_GET['xyz']) ) {
define('WP_DEBUG', true);
}

Then just add ?xyz to the end of a URL to show error messages. Handy when you have a problem on the live server and want to see what the error message is.