Git push deployment

Before you get started using git push to deploy changes to your site, we assume the following:

  • You already have a website set up on Templ that you want to push changes to.
  • You have an existing git repo that you want to push changes from, e.g. on a local development environment.

Prepare your site on Templ

First you need to create a bare git repo on your Templ site.

Connect to your site using SSH and create a bare git repo:

git init --bare wordpress.git

Then we need to add a script for the files to actually be updated when changes are pushed to the repo:

nano wordpress.git/hooks/post-receive

Insert following content:

#!/bin/bash
git --work-tree=/home/user_xxxx/app_xxxx --git-dir=/home/user_xxxx/wordpress.git checkout -f

Make the script executable:

chmod +x wordpress.git/hooks/post-receive

Add your remote repo to your local environment and push

Now we can go to our local git repo that we want to push changes from, and add our remote repo that's on Templ:

git remote add templ ssh://[email protected]:xxxxx/home/user_xxxx/wordpress.git

And now we can push changes to Templ like so:

git push templ main

If your repo uses the older master branch name instead of main, push that branch instead:

git push templ master

You can check your current branch name with git branch --show-current.