Are you using git yet? Are you deploying your website via git push? - You should!

The goal of this post is to give you a short overview of my way to get git automatically deploy a website via git push on

I will use as domain and metalmatze as examples (my site is not hosted on uberspace).

What we want to do

  1. git push uberspace master - This will push new commits to uberspace and deploy your site.
  2. Check to see the changes we just pushed.


Connect with ssh to uberspace.

$ ssh

Create a new folder in your home directory (you should be there after connecting) called

$ mkdir

Change into this directory with cd

Next we want to create a bare git repository

$ git init --bare
Initialized empty Git repository in /home/metalmatze/

The following steps will take place in your local repository!

Now we want to add uberspace as a remote repository to our local repository

$ git remote add uberspace ssh://

The following steps will take place on uberspace in the bare git repository!

To get git to deploy our website into a specified folder we’ll use a post-receive hook.

Open hooks/post-receive with an editor like vim or nano.

$ vim hooks/post-receive

Into this file we’ll paste a simple bash script that will deploy the master branch into /home/metalmatze/html/


echo "========= GIT CHECKOUT ========="
GIT_WORK_TREE=$path git checkout -f master

echo "============= DONE ============="

Save and exit the editor.

Don’t forget to change the file permissions to be executable.

$ chmod u+x hooks/post-receive

At last we need to link to our folder where we deployed’s into.

$ cd /var/www/virtual/metalmatze

$ ln -s html/

Now go on with your browser and check out your automatically deployed website!

Isn’t that awesome?!


We are now able to deploy our changes with only one git command, or even with a GUI.

Do you have any questions or comments? Please leave them below. Thanks!