How to use git to manage one codebase but have different environments

后端 未结 2 1194
青春惊慌失措
青春惊慌失措 2020-12-18 00:00

I\'m using git for a personal project at the moment and have run into a problem of having one codebase for two different environments and was wondering what the cleanest way

2条回答
  •  星月不相逢
    2020-12-18 00:45

    The way I do it...

    ...is not commit environment specific files via .gitignore.

    In CodeIgniter this means

    • .htaccess
    • database.php
    • config.php

    That's about it.

    Depending on how your application is setup this can have differing effects. Mostly I will have say config.example.php and example.htaccess which I will commit. Then if I have to setup an environment I will modify those and rename them in the process. Because they are ignored by git you don't have to worry about it.

    If you have lots of environment specific code then you need to rethink the layout of your application.

提交回复
热议问题