Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git post-receive [[ not found

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?

like image 507
Get Off My Lawn Avatar asked Oct 18 '25 08:10

Get Off My Lawn


1 Answers

[[ … ]] isn’t POSIX-shell-compatible; you probably want bash or something similar.

#!/bin/bash
like image 170
Ry- Avatar answered Oct 19 '25 20:10

Ry-



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!