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

后端 未结 2 1191
青春惊慌失措
青春惊慌失措 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:30

    I think it is too late for the .gitignore solutions.

    I would :

    • create a laptop branch on your desktop machine machine
    • pull your changes from your laptop on this branch
    • checkout the config file which should not have changed from the master branch
    • verify it works and twiddle till it does
    • commit it
    • checkout the master branch
    • merge it with the laptop branch
    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题