当我在本地计算机上运行“git push”时,我正试图在服务器上执行钩子。我可以从本地计算机上推送代码,当我从服务器上的命令行运行“git pull”时,更改将正确拉动。
这是hooks目录的样子:
sbirds@[xxx].com [~/public_html/app]# ls -l .git/hooks/
total 32
drwxr-xr-x 2 sbirds sbirds 2048 Mar 31 18:41 ./
drwxr-xr-x 8 sbirds sbirds 2048 Mar 31 18:33 ../
-rwxr-xr-x 1 sbirds sbirds 452 Mar 30 00:24 applypatch-msg.sample*
-rwxr-xr-x 1 sbirds sbirds 896 Mar 30 00:24 commit-msg.sample*
-rwxr-xr-x 1 sbirds sbirds 160 Mar 30 00:24 post-commit.sample*
-rwxr-xr-x 1 sbirds sbirds 552 Mar 30 00:24 post-receive.sample*
-rwxr-xr-x 1 sbirds sbirds 45 Mar 31 18:31 post-update*
-rwxr-xr-x 1 sbirds sbirds 189 Mar 30 00:24 post-update.sample*
-rwxr-xr-x 1 sbirds sbirds 398 Mar 30 00:24 pre-applypatch.sample*
-rwxr-xr-x 1 sbirds sbirds 1578 Mar 30 00:24 pre-commit.sample*
-rwxr-xr-x 1 sbirds sbirds 4951 Mar 30 00:24 pre-rebase.sample*
-rwxr-xr-x 1 sbirds sbirds 1239 Mar 30 00:24 prepare-commit-msg.sample*
-rwxr-xr-x 1 sbirds sbirds 3611 Mar 30 00:24 update.sample*
现在,我只是运行一个创建新目录的简单脚本。当我从命令行手动执行此脚本作为“sbirds”用户时,它成功创建了该目录。这是脚本的样子:
sbirds@[xxx].com [~/public_html/app]# cat .git/hooks/post-update
#!/bin/sh
mkdir $HOME/public_html/app/hook_folder
配置文件:
sbirds@[xxx].com [~/public_html/app]# cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = sbirds@[xxx].com:/home/sbirds/repositories/app.git
fetch = +refs/heads/*:refs/remotes/origin/*
操作系统信息:
sbirds@[xxx].com [~/public_html/app]# cat /proc/version
Linux version 2.6.18-028stab070.5 (root@rhel5-build-x64) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Fri Sep 17 15:37:23 MSD 2010
对我所做错的任何建议都会非常感激。