Skip to content

Instantly share code, notes, and snippets.

@janeklb
Last active Dec 24, 2015
Embed
What would you like to do?
Easy peezy deploy from a git repo using rsync
#!/bin/sh
# heavily inspired by http://wildlyinaccurate.com/deploying-a-git-repository-to-a-remote-server (and comments)
ref=master # git ref
prefix=deploy_in_prog/ # just a temp name
tmp_dir=/tmp
remote_dir=/var/www # the remote directory
remote_host=user@host # the remote host
echo "Deploying to $remote_dir..."
git archive --prefix=$prefix $ref | tar -x -C $tmp_dir | rsync $tmp_dir/$prefix --copy-links -av $remote_host:$remote_dir
rm -rf $tmp_dir/$prefix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment