I have a git hook (post-receive
), that looks like this:
#!/bin/sh
cd /home/vservices
while read OLDSHA NEWSHA REF ; do
if [[ "$NEWSHA" == "0000000000000000000000000000000000000000" ]]; then
git --git-dir=/home/vservices/.git --work-tree=/home/vservices fetch -p origin
else
git --git-dir=/home/vservices/.git --work-tree=/home/vservices pull
fi
done
And I am getting this error message when I run git push dev :test2
:
remote: hooks/post-receive: 10: [[: not found
remote: Your configuration specifies to merge with the ref 'test2'
remote: from the remote, but no such ref was fetched.
I don't know much about sh
, so what am I doing wrong?
[[ … ]]
isn’t POSIX-shell-compatible; you probably want bash
or something similar.
#!/bin/bash