2017-07-17 109 views
0

我正在尝试使用git将更改部署到本地托管的服务器上的站点。当我将更改从本地目录推送到开发服务器时,post-receive钩子提供了我期望的反馈,如果它正在工作,但它实际上并不改变工作树中的任何文件。Post-Receive Hook不会错误但不会复制文件

此外,我在Mac开发和网站托管在网络上共享的Windows服务器上,并安装到/卷/ I $

这里是钩子脚本

#!/bin/bash 

GIT_DIR=/Volumes/I$/intranet_dev 
WORK_TREE=/Volumes/I$/intranetdev 

while read oldrev newrev ref 
do 
    if [[ $ref =~ .*/master$ ]]; 
    then 
     echo "Master ref received. Deploying master branch to test server..." 
     mkdir -p $WORK_TREE 
     git --work-tree=$WORK_TREE --git-dir=$GIT_DIR checkout -f 
     echo "Git hooks deploy complete" 
    else 
     echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server." 
    fi 
done 

的裸仓库位于我标记为“测试”的远程位置。当我发出以下命令,我得到下面的输出在我的终端...

computername:intranet username$ git push test master 
Counting objects: 6, done. 
Delta compression using up to 8 threads. 
Compressing objects: 100% (6/6), done. 
Writing objects: 100% (6/6), 566 bytes | 0 bytes/s, done. 
Total 6 (delta 5), reused 0 (delta 0) 
remote: Master ref received. Deploying master branch to test server... 
remote: Git hooks deploy complete 
To /Volumes/I$/intranet_dev 
    1d9eb1f..f49b533 master -> master 

这一切看起来,因为它应该,但更改文件不会被复制。

+1

您正在检出当前的HEAD。你确定这是连接到'master'分支?为什么依靠这个?尝试检查'master'。小点:'如果[[$ ref = * master]]'是你所需要的, – jthill

+0

我会试一试。这个脚本是基于我从数字海洋中获得的一个,所以我只是用他们的建议。听起来很好,但是。 – unclesol

+0

这个伎俩!发布它作为答案,我会将其标记为正确。 – unclesol

回答

0

您正在查看当前的HEAD。你确定这是附属于主分支?为什么依靠这个?请尝试检出master

小点,if [[ $ref = */master ]](或者只要我们安全,所有,@ torek指出,if [[ $ref = refs/heads/master ]])是你需要的。

相关问题