mcottondesign

Loving Open-Souce One Anonymous Function at a Time.

Deploying with Git

I want to deploy new code to using a simple command like

git push stage master

or

git push prod master

On the server, make a new git repository

git init

Edit the config file inside of .git/

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true

[receive]
    denyCurrentBranch = ignore

Make a post-receive hook with these commands

#!/bin/sh
cd .. 
GIT_DIR='.git' 
umask 002 && git reset --hard

Make that hook exacutable

chmod +x post-receive

On your machine (not the server)

Add the a new git remote, I edited my local copy and duplicated what I had setup for origin