这已被问过很多次,我经历了无数的线程和谷歌页面,但似乎没有人能解决我的问题。也许我不是以标准的方式做到这一点,但它应该仍然有效。
我有一台有git repo的远程服务器
我通过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 - 接收
收到后的内容是:
#!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
。任何关于你认为其原因可能是什么的提示都会被扼杀!
P.S。钩子文件夹上的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
编辑:我有进步。我使用Git GUI来查看更详细的输出,而不是从NetBeans IDE推送。以下是我推送到远程时发生的事情: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?
答案 0 :(得分:5)
您缺少脚本的hash-bang(1st)行的前导/。
以下是其他一些调试技巧:
请注意,您可以使用$ GIT_DIR来查找与回购相关的内容。
另一个想法是打开shell中的echo。
#!/ bin / bash -x
然后遥控器应该准确显示哪条线让你感到悲伤。
最后,我认为SUBJECT =行上的嵌套引号存在问题。 您可以使用单引号作为内部引号。 LOGFILE有同样的问题。