Skip to content

How to set up Git Hooks

Daisho Komiyama edited this page Jan 20, 2018 · 15 revisions

Hello, I'm going to write down what I just did for setting up Git Hooks for daishodesign.com.

Create a directory

Create a directory site-daishodesign.git under /var/repo/

Initiate Git

Initiate with bare flag git init --bare The commande above should have created the directory hooks/. Navigate into it.

Create post-receive file

Create it under hooks/ sudo nano post-receive

Edit post-receive file

Open it with nano then add this line. #!/bin/sh git --work-tree=/var/www/daishodesign.com/html --git-dir=/var/repo/site-daishodesign.git checkout -f

Create symbolic link

Create symlink from server block file to a directory sites-enabled sudo ln -s /etc/nginx/sites-available/daishodesign.com /etc/nginx/sites-enabled/

Give permissions

Give execution permissions to post-receive file sudo chmod +x post-receive

Add production remote to local git

Go back to local, then add a production remote git remote add production ssh://root@daishodesign.com/var/repo/site-daishodesign.git

Clone this wiki locally