Git post-receive [[未找到

时间:2014-07-14 22:54:08

标签: git sh githooks git-post-receive

我有一个git hook(post-receive),看起来像这样:

#!/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

我在运行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.

我对sh了解不多,所以我做错了什么?

1 个答案:

答案 0 :(得分:11)

[[ … ]]与POSIX-shell不兼容;你可能想要bash或类似的东西。

#!/bin/bash