git pull忽略shell脚本中的当前工作目录

git pull忽略shell脚本中的当前工作目录,git,shell,sh,git-pull,cd,Git,Shell,Sh,Git Pull,Cd,我正在尝试某种自动部署工作 我当前的更新后挂钩如下所示: #!/bin/sh for ref in $@ do if [ $ref = "refs/heads/master" ] then echo "Deploying $ref to dev-domain" cd ~/www/dev-domain echo "" > system/lock

我正在尝试某种自动部署工作

我当前的更新后挂钩如下所示:

#!/bin/sh

for ref in $@
do
        if [ $ref = "refs/heads/master" ]
        then
                echo "Deploying $ref to dev-domain"
                cd ~/www/dev-domain
                echo "" > system/lock
                if ! git pull --ff-only
                then
                        echo "Failed to pull"
                        exit
                fi
                if ! system/migrateDatabase
                then
                        echo "Failed to migrate"
                        exit
                fi
                rm system/lock
        fi
done
但我得到的只是:

remote: Deploying refs/heads/master to dev-domain
remote: fatal: Not a git repository: '.'
remote: Failed to pull
不过,文件锁定文件将放置在正确的位置

因此,在我看来,它似乎是
git pull
以某种方式忽略了当前的工作目录。。。我该怎么做?
还是我遗漏了一些不同的内容?

您需要在
GIT pull
之前取消设置
GIT\u DIR

如果不这样做,git将使用而不是PWD。
cd-ing更改PWD而不是GIT_目录

正如在的文章中提到的那样,“
GIT\u DIR
是由hook设置的


请参阅“by.

中的更多内容。我忘了说,如果我直接(在交互式shell中)运行这些命令,它将按预期工作。