Git – How to deploy code from my central Git repo to my production server?

I’m new to Git. I need to setup Git to deploy a Django website to the production server. My question here is to know what is the best way of doing this.

By now I only have a Master branch. My problem here is that Development environment is not equal to the Production environment. How can I have the two environments(Development and Production) in Git? Should I use two new Branches(Development and Production). Please give me a clue on this.

  • git update/patch on remote host without internet
  • Best strategy to deploy static site to s3 on github push?
  • Deploy a PHP project from Git to a server that does not have Git installed
  • Is it safe to run your site within a Git repository on your production server?
  • Heroku/python failed to detect set buildpack
  • What's your ideal branch architecture within git for web applications?
  • Other question… when I finish to upload/push the code to the Production server I need to restart the Gunicorn(serves Django website). How can I do this?

    And the most important question… Should I use Git to do this or I have better options?

    Best Regards,

  • How to see remote changes to branches in Git?
  • Cannot push changes to repository (GIT)
  • Finding the size of a push
  • Visual Studio Failed to clone the remote repository (Early EOF) - GIT
  • git-instaweb and git-clone
  • Smartgit: Auto insert commit message
  • 2 Solutions collect form web for “Git – How to deploy code from my central Git repo to my production server?”

    The first question you must solve is your project structure. Usually the difference between development and the production environment is and So why you firstly separate those? 🙂 For example you can have one main where you define all the default settings which are in common. Then at the end of the file you just import the and for exemple:

        from settings_prod import *
    except ImportError:
        from settings_dev import *
    except ImportError:

    Then simply you can overload all the setting you want and have custom settings of the project (for example installed apps). The same logic you can use for file.

    Then you can simply ignore adding the *_dev files to repo and on the server side you can just checkout the code from repo and restart http server. To automatize this for now I can’t give the right name of app to use. Sometimes simple python script could be solution like: watching if the file datetime changed and if yes, just run restart command for http.

    Hope that helped.


    You can follow this brunching model –

    And, git is ok but use Fabric for deployment.

    Git Baby is a git and github fan, let's start git clone.