Skip to content

Instantly share code, notes, and snippets.

@monkeycycle
Forked from danriti/README.md
Last active August 29, 2015 14:24
Show Gist options
  • Save monkeycycle/828539a43a74703575bf to your computer and use it in GitHub Desktop.
Save monkeycycle/828539a43a74703575bf to your computer and use it in GitHub Desktop.
Git deploy to anywhere

Instructions

Put your ssh key on the server:

$ ssh-copy-id username@remote-server.org

On the server, create a bare git repo:

$ mkdir website.git
$ cd website.git
$ git init --bare

On the local machine, add the server repo as a remote host:

$ git remote add production ssh://username@remote-server.org/~/git/website.git

Finally, add the post-receive script attached to this Gist.

Now you can push to your new production repo:

$ git push production master

References:

#!/bin/sh
echo 'Deploying to Production...'
GIT_WORK_TREE=/home/example/example.com git checkout -f
echo 'Success!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment