Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding basic git hooks

Tags:

git

bash

I'm new to both git and unix so please bear with. I'm trying to create a simple git post-receive hook in a repository I've setup on ec2. In the hooks folder, I have a file named post-receive that attempts to update a public site's working directory.

#!/bin/sh

echo 'hi git'
cd /home/www-data/web2py/applications/init
sudo git checkout .
sudo git pull
echo 'done'

But after a push, nothing seems to happen. The site's working directory does not get updated and when I run git log there are no signs of errors or my echo statements. I guess I'm missing something? Thanks.

like image 505
Dane Avatar asked Oct 14 '22 17:10

Dane


1 Answers

First: git log is not the log of the git binary. :) It is used to see the commits and their revisions.

Do you see the "hi git" and "done" output somewhere? My guess is that your hook is not executable. Run chmod +x your_hook - This will make it executable.

like image 55
Lennart Koopmann Avatar answered Oct 17 '22 00:10

Lennart Koopmann