Skip to content

Instantly share code, notes, and snippets.

@janeklb
Last active December 24, 2015 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janeklb/6786988 to your computer and use it in GitHub Desktop.
Save janeklb/6786988 to your computer and use it in GitHub Desktop.
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