我有一个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
了解不多,所以我做错了什么?
答案 0 :(得分:11)
[[ … ]]
与POSIX-shell不兼容;你可能想要bash
或类似的东西。
#!/bin/bash