Skip to content

Instantly share code, notes, and snippets.

@shrestharikesh
Last active September 21, 2020 04:49
Show Gist options
  • Save shrestharikesh/0fb694ba1979a0ad3b807b549f3cd1d3 to your computer and use it in GitHub Desktop.
Save shrestharikesh/0fb694ba1979a0ad3b807b549f3cd1d3 to your computer and use it in GitHub Desktop.
Automatic deployment with GIT in a VPS. Create a git hook on VPS.
cd /my/workspace
mkdir project && cd project
git init
git remote add live ssh://user@mydomain.com/var/repo/site.git
git add .
git commit -m "My project is ready"
git push live master

cd /var
mkdir repo && cd repo
mkdir site.git && cd site.git
git init --bare
cd hooks
cat > post-receive
#!/bin/sh
git --work-tree=/var/www/domain.com --git-dir=/var/repo/site.git checkout -f
Press: ctrl + d (saving to file)
chmod +x post-receive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment