Git: git-deploy

Fortunately git is easy to extend. I'd like to share a very short but useful git extension with you: git-deploy. If you didn't know, git can easily be extended by having an executable on your path with the git- prefix. Therefore, an executable file named git-cats can be invoked via git cats, git-scrub via git scrub and so forth.

We're using a short shell script to generate a zip file that contains only the differences from the last deploy. In this manner it's easy for us to transfer only those files that have changed. The limitations of this approach are that deletes are not included, nor are database changes (obviously).

The script follows:

#!/bin/sh

if [ -z "$1" ]
then
echo "usage: $0 <from> [to-file]"
exit
fi

patch_file="$2"
if [ -z "$patch_file" ]
then
patch_file="patch.zip"
fi

git archive --format=zip HEAD $(git diff-tree -r --name-only --diff-filter=AM $1..HEAD) > $patch_file

To use this script copy it into your path so that it is executable. Give it a whirl by typing: git deploy. It should give you a warning such as: usage: git-deploy <from> [to-file].

The script works by comparing a given commit against the head, and stuffing the difference into a zip archive called patch.zip. This process works very well with tags, especially if each release is tagged appropriately. Be sure that the commit specified is an ancestor of the current head, otherwise you may end up with an archive of everything in HEAD.

© Carousel30 Interactive Media -
Washington, DC, Maryland, Virginia.

All rights reserved. Site Map

Client Login

Interactive / Web Design & Development:
Online Marketing Strategy
Web site Design & Development
Flex, Flash & AIR Development
Flash Games Design & Development
Content Management System Development
iPhone Application Development

Web Marketing:
Search Engine Optimization
Social Media Marketing
Video / Film:
Motion Graphics Capabilities