Setting up a remote bare git repository

A git repository is where the version control is handled (pull / push / history / etc).

A bare repository as the version control without a working copy of the files alongside it.

Set up Repo

  1. Open Terminal
  2. Connect to the server via SSH
    ssh -p 2020 root@194.39.166.106.srvlist.ukfast.net
  3. Enter the server password
  4. Navigate to var/repo/
  5. Create a new ‘bare’ .git file for the website
    mkdir filename.git
    cd filename.git
    git init --bare

Set up the ‘Hook’ which triggers the actions in the website directory

  1. Navigate to the Hooks directory
    cd hooks
  2. Create a new bash called ‘post-receive’, you can do this part either via command line or a code editor e.g. Coda
  3. Set up the Action – paste the following into the post-receive file
    Replace work-tree with the correct path
    Replace git-dir path with the path to the bare git repository e.g. /var/repo/filename.git
    Master (branch) is an optional parameter. If not specified the default will be ‘master’.
    #!/bin/sh
    git --work-tree=/home/ttbtheatre/public_html/wp-content/themes/theatre-centre --git-dir=/var/repo/theatre-centre-build.git checkout -f master
  4. Set the file as executable
    chmod +x post-receive

Naming conventions for bare repos

The theme / website name followed by:
–build for staging or
— live for live websites

e.g. Theatre Centre Staging = theatre-centre-build.git
e.g. Theatre Centre Live = theatre-centre-live.git

Twentytwo Digital

General updates from the team.