Search code examples
gitdevelopment-environmentproduction-environment

Handling different configurations with git


I am doing a Laravel 4 project, and there is an option on mail.pjp, where you can pretend to send an email, but you actually are logging it locally into a file. This is useful for development.

The problem I have is with version control. If I check in, this option as "true", then I risk that when I update the production server, it might disable emails if I am not careful.

On the other hand, if I check in the file in git as "true", it might happen what happened today, that I lost a good couple of hours trying to understand why the mail was not working because I forgot I had to change this option for my development environment.

What way could I handle these "production vs development" configuration issues with git?


Solution

  • Have a branch for each configuration.

    For instance, you could have a production branch and a dev branch.

    On the production branch, just make one commit to change the configuration file, then use the dev branch the same way you used your master branch.

    The deployment process becomes

    On dev:

    • git checkout production
    • git merge dev
    • git push origin production

    On production:

    • git pull origin production

    Or split your configuration file

    And maybe add some runtime test to pick the good one at the right time.