Skip to content

Instantly share code, notes, and snippets.

Last active October 13, 2015 09:47
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Git Deployment Post Receive


Put your ssh key on the server:

$ ssh-copy-id

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://

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

Now you can push to your new production repo:

$ git push production master


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