Using git to push websites to server

This cheatsheet will push your repo to the app directory inside a user home directory in the remote server.
  • Remote/Server (domain name or IP):
  • User on Server :
  • Project Dir :
  • SSH Port :

SSH into the server

mkdir repo.git app
cd repo.git
git init --bare
git --bare update-server-info
git config core.bare false
git config receive.denycurrentbranch ignore
git config core.worktree /home/user/app/

cat > hooks/post-receive <<EOF
git checkout -f

chmod +x hooks/post-receive


On the client

git remote add server [email protected]:/home/user/repo.git/
ssh-copy-id [email protected]
git push server --all

You may want to modify your git post-receive hook to run custom commands on the server, like running database migrations, notifying services of new deployments, pushing static files to CDN, etc.