Giter Club home page Giter Club logo

gitdeploy's Introduction

GitDeploy

Git as deploy tool http://wanhaoran.tumblr.com/post/30795177352/git-as-deployment-toolgit as deployment tool

What was the problem?

My company has a large php website. Changes developed for the web site were released as a small set of files packed up manually. Because the company had a tradition of making changes directly on production server, before deploying changes to production, a copy of production php files were compared with SCM contents. And the developer needed to incorporate the difference with the release files. This deploy process was manual and quite error-prone. There was no version control of the web site at all because SCM has no control over production.

Options

We have considered full tar ball deployment and git patch file deployment. Full tar ball method is bad because changes done directly on production will be lost. Recover them might be costly. git patch file requires good knowledge of git and good understanding of the code being released. Unix admins don’t have either of them. My colleague came across an idea to use git as deployment tool. Google lead us to Using Git for Deployment. By setup php working dir as git repository, we can deploy changes quick and safe. Unix admins doesn’t need any knowledge of either git or the code base. We can pack the commands for deployment in shell scripts. The other difficult thing to handle is changes done directly on production server.

Solution

Fortunately git has a utility called stash. With stash, I managed to handle changes done directly on server. We have two deployment scripts written up, one for overnight update, the other for manually initiated release. There are two main steps for the release: Check for local changes Pull in difference from a branch Check for local changes is done by running a stash command and check if any stash is created. Pull in difference is a straight pull from a certain branch in a central repo. Overnight and manual release have different logic in determining whether to pull. If local changes are found, overnight update will report it, re-apply the stashed changes back and not pull any difference; where as manual release will report it but pull the difference. If no local changes are found, difference will be pulled in. Also we installed a pre-commit hook to stop commit on server.

gitdeploy's People

Contributors

michaelwan avatar

Stargazers

Dom avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.