Peter Warbo
Peter Warbo

Reputation: 11700

Git 2 versions of one file

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.

Upvotes: 1

Views: 221

Answers (1)

usumoio
usumoio

Reputation: 3568

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.

Upvotes: 1

Related Questions