Search code examples
gitdrupal-7synchronizationdevelopment-environmentproduction-environment

Syncing Development & Production Servers


I've got a web app that runs off of Drupal (7) on a Linux machine. Normally I'll create a sub domain such as "dev.example.com" and make my changes and bug fixes before they go live. When I'm ready to push them to production, I've got to go through each file that I've modified or created and bring them to the production domain. I'm thinking there has to be a better - I just don't know any better.

I know lots of people use GIT. I'm curious how I can incorporate that into my workflow. Does it mean I've got a copy of all my custom code up on GIT and then I just fork it when I'm ready to make changes? Then take the code from GIT to my web server. I'm not too clear how it all works.

Any ideas, suggestions or tips would be greatly appreciated. I've always wondered about the "right" way to do this stuff, now I finally have a reason to learn.

Best, Howie


Solution

  • The right way,

    Initialization:

    • Keep your code to any git repository. Popular free git repositories are github and bit bucket.
    • Checkout out your code to your local machine. Default branch will be master.

    Development workflow:

    • Make another branch 'development' which is responsible to contain all the code during development.
    • For any kind of bug fixing or feature development create a new branch from 'development' branch.
    • Do changes, commit, push and merge to 'development' branch. And test from this branch.
    • If everything OK, merge development branch to master.
    • For more, you can check this out: http://nvie.com/posts/a-successful-git-branching-model/

    Deployment to server:

    • Prepare a staging server which is exact copy of production.
    • Use build automation tools like jenkins + ant script to fetch your code from git and place in staging server.
    • Test from there.
    • If OK, copy your codes to production
    • Clear all cache :)

    Deployment in easier way

    • Checkout your code to production server. Remain in master branch.
    • Whenever you want to release, just execute 'git pull' command.

    Happy Deploying :)