-
Notifications
You must be signed in to change notification settings - Fork 0
How to set up Git Hooks
This is a note about what I've done for setting up Git Hooks. The website is daishodesign.com.
domain is already taken and setup.
Create a directory site-daishodesign.git
under /var/repo/
Initiate with bare flag
git init --bare
The commande above should have created the directory hooks/
.
Navigate into it.
Create it under hooks/
sudo nano post-receive
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 symlink from server block file to a directory sites-enabled
sudo ln -s /etc/nginx/sites-available/daishodesign.com /etc/nginx/sites-enabled/
Give execution permissions to post-receive
file
sudo chmod +x post-receive
Go back to local and navigate to the root directory of your site to add a production remote
git remote add production ssh://root@daishodesign.com/var/repo/site-daishodesign.git
That's it.
You can push your commits with
git push origin master
to your Github repo and you can also push all your changes to production with
git push production master
It's super fast compared to sending all files using a FTP software. Not only it's faster but also safer because you can't miss files that you changed.