这个问题已经被问了很多次,我查看了无数的帖子和谷歌页面,但似乎没有一个能够解决我的问题。也许我没有按照标准方法操作,但它应该仍然有效。
我有一个远程服务器,上面有一个git仓库。
我通过ssh从本地推送到它:
推送工作正常,远程仓库已更新。我可以使用putty并运行
我必须指出,手动执行该文件可以按预期发送电子邮件。但从未作为钩子触发。甚至没有
我有一个远程服务器,上面有一个git仓库。
我通过ssh从本地推送到它:
git add Y:\NetBeansProjects\pics\pics-client-branding\src\main\java\com\waudware\pics\viewer\TypeTopComponent.java
git commit -m Testing GIT Friday 8 Y:\NetBeansProjects\pics\pics-client-branding\src\main\java\com\waudware\pics\viewer\TypeTopComponent.java
Commit Log
revision : b2d7fd5cbafbfddfccf8d3c8ac75614c4b357887
author : Denis <Denis@WWOscar.Waudware.local>
date : Jun 21, 2013 3:21:47 PM
summary : Testing GIT Friday 8
INFO: End of Commit
==[IDE]== Jun 21, 2013 3:21:48 PM Committing... finished.
==[IDE]== Jun 21, 2013 3:21:52 PM Pushing
git push ssh://wwbert/cygdrive/d/Shared_Data/Development/dev_NetBeans/Projects/PICS.git +refs/heads/master:refs/heads/master
Remote Repository Updates
Branch : master
Old Id : e51af3dbc01ee2372f9c92bb8070cb1100bef220
New Id : b2d7fd5cbafbfddfccf8d3c8ac75614c4b357887
Result : OK
Local Repository Updates
Branch : origin/master
Old Id : e51af3dbc01ee2372f9c92bb8070cb1100bef220
New Id : b2d7fd5cbafbfddfccf8d3c8ac75614c4b357887
Result : FAST_FORWARD
==[IDE]== Jun 21, 2013 3:21:56 PM Pushing finished.
推送工作正常,远程仓库已更新。我可以使用putty并运行
git show
轻松检查。然而,我编写的post-receive钩子不会运行。远程git项目文件夹是:wwbert/cygdrive/d/Shared_Data/Development/dev_NetBeans/Projects/PICS.git,钩子位于wwbert/cygdrive/d/Shared_Data/Development/dev_NetBeans/Projects/PICS.git/hooks/post-receive。
post-receive的内容如下:#!bin/sh
touch worked.txt
SMTPSERVER=10.0.0.2
FROM=git-push-alert@waudware.com
TO=denis@waudware.com
SUBJECT="Subject: GIT [commit] $(date +"%m-%d-%Y")"
LOGFILE="commit-$(date +"%m-%d-%Y").log"
DIFF=1
SHORTLOG=1
echo "$SUBJECT" > ../logs/"$LOGFILE"
echo >> ../logs/"$LOGFILE"
git log --since=yesterday >> ../logs/"$LOGFILE"
if [ "$DIFF" == "1" ]; then
git show --pretty >> ../logs/"$LOGFILE"
fi
git send-email --smtp-server "$SMTPSERVER" --to "$TO" --from "$FROM" ../logs/"$LOGFILE"
我必须指出,手动执行该文件可以按预期发送电子邮件。但从未作为钩子触发。甚至没有
touch
。您认为可能是什么原因,请提供任何提示!
附注:ls -la
的钩子文件夹:WAUDWARE\denis@WWBert /cygdrive/d/Shared_Data/Development/dev_NetBeans/Projects/pics.git/hooks
$ ls -la
total 38
drwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 4096 2013-06-21 15:20 .
drwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 4096 2013-06-21 14:48 ..
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 452 2013-04-23 10:02 applypatch-msg.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 896 2013-04-23 10:02 commit-msg.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 160 2013-04-23 10:02 post-commit.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 514 2013-06-21 16:08 post-receive
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 552 2013-04-23 10:02 post-receive.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 189 2013-04-23 10:02 post-update.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 398 2013-04-23 10:02 pre-applypatch.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 1578 2013-04-23 10:02 pre-commit.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 4951 2013-04-23 10:02 pre-rebase.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 1239 2013-04-23 10:02 prepare-commit-msg.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 3611 2013-04-23 10:02 update.sample
编辑:我有所进展。我不再使用NetBeans IDE推送,而是使用Git GUI查看更详细的输出。以下是我推送到远程时发生的情况:remote: fatal: cannot exec 'hooks/post-receive': Permission denied[K
To ssh://WAUDWARE\denis@wwbert/cygdrive/d/Shared_Data/Development/dev_NetBeans/Projects/PICS.git
ab6ddef..a5644e8 master -> master
。您可以在邮件中看到我的权限。它们有什么问题吗?还有其他权限可能会阻止post-receive执行吗?
touch worked.txt
似乎没有出现在pics.git目录或pics.git/hooks/中 =( 日志目录位于pics.git/logs/中。根据您的说法,post-receive将像从pics.git运行一样,因此我不需要上升一个级别? - Metal Wing../logs/
更改为logs
,好像它是从 pics.git 目录运行的;但是,仍然没有运气。如果作为sh hooks/post-receive
执行脚本仍然有效,但是当我从本地推送到远程时就不行了 :/ - Metal Wingremote: fatal: cannot exec 'hooks/post-receive': Permission denied[K To ssh://WAUDWARE\denis@wwbert/cygdrive/d/Shared_Data/Development/dev_NetBeans/Projects/PICS.git ab6ddef..a5644e8 master -> master
。您可以在后面看到我的权限。它们有什么问题吗?还有其他权限可能会阻止post-receive的执行吗? - Metal Wing