Is it possible to have 2 versions of one file in Git? Probably not, but what options do you have? I have a scenario where I'm working on something that depending on where it's deployed (production or staging) a configuration file should look different whether it's deployed in production or staging environment.
Asked
Active
Viewed 124 times
0
-
Usually it's appropriate to keep two configuration files in that instance, and have your framework/code determine what environment its in, in order to pick the config file that's needed. Symfony2 is a good example where you can have the `app_dev.php` bootstrapper file load the config parameters. – sjagr May 21 '15 at 20:18
-
I need to have 2 versions of robots.txt, How can I do this? – Peter Warbo May 21 '15 at 20:41
-
http://stackoverflow.com/questions/20078756/making-git-retain-different-section-content-between-branches/20087076#20087076 might help – jthill May 21 '15 at 20:45
-
Found the answer here: http://stackoverflow.com/questions/15119760/what-is-the-smartest-way-to-handle-robots-txt-in-express – Peter Warbo May 21 '15 at 20:48
1 Answers
1
This is not really a good job for Git. Pretty much every server language allows something like this:
public $default_url = $_SERVER[ 'url' ];
// note I'm using PHP to show this
if( $default_url === 'www.your_production.com' ) {
load('production.conf');
} else {
load('staging.conf');
}
Check about accessing your server variable to figure out where you are, that will give you the info you need to figure this out.

usumoio
- 3,500
- 6
- 31
- 57
-
-
1Found the answer here: http://stackoverflow.com/questions/15119760/what-is-the-smartest-way-to-handle-robots-txt-in-express – Peter Warbo May 21 '15 at 20:47