Windows下的Git钩子

Windows下的Git钩子,windows,git,post,hook,Windows,Git,Post,Hook,我要在hook post receive的工作目录中签出以下代码: #!/bin/sh git --work-tree=d:/websites/__gitweb --git-dir=d:/_gitrepo.git/ checkout -f 不幸的是,它似乎不起作用。但是,当我在windows命令行(cms)中仅输入以下内容时,该命令确实有效: 我已经检查了权限和执行属性,但什么都没有 更新: 我想我越来越近了。现在我知道问题是什么,但我不知道为什么会发生这种情况。钩子实际上已被触发,但我收到以

我要在hook post receive的工作目录中签出以下代码:

#!/bin/sh
git --work-tree=d:/websites/__gitweb --git-dir=d:/_gitrepo.git/ checkout -f
不幸的是,它似乎不起作用。但是,当我在windows命令行(cms)中仅输入以下内容时,该命令确实有效:

我已经检查了权限和执行属性,但什么都没有

更新:

我想我越来越近了。现在我知道问题是什么,但我不知道为什么会发生这种情况。钩子实际上已被触发,但我收到以下消息:

remote: Starting copy from repository to work tree...
remote: fatal: Not a git repository: 'd:/_gitrepo.git/'
remote: Finished.
我曾尝试将d:的路径更改为整个网络路径,但仍然不起作用。如果我转到远程存储库并做一个git日志,更改就在那里,如果我用sh运行钩子,它就会工作。 为什么说它不是git存储库,而事实上它是?

对于shell脚本(这些钩子脚本将作为shell执行,甚至在Windows中,通过),您可以使用不同的路径:

#!/bin/sh
git --work-tree=/d/websites/__gitweb --git-dir=/d/_gitrepo.git/ checkout -f
还可以使用“

查看其他可能性。我终于让它工作了! 这真的很奇怪。我必须键入一个
pwd
来查看批处理的实际位置,它显示了钩子在服务器上的位置。但是,在下一行中,我添加了一个
hostname
,它显示了我的本地主机名。 然后我添加整个路径,如下所示:

#!/bin/sh
echo "Starting copy from repository to work tree..."
pwd
hostname
git --work-tree=//remotehost/d$/Webseiten/__gitweb --git-dir=//remotehost/d$/_gitr
epo.git checkout -f
echo "Finished."

我希望此解决方案适用于尝试删除
#的人

/bin/sh
顶行?Windows不支持。嗨,吉米,谢谢你的回复。我试过了,但仍然不起作用。在你的情况下,这个命令的输出是什么?如果您在windows上,在使用msysgitHi时,您可以使用类似于
/d/websites/\uu gitweb
的路径!我已经试过了,如果我输入Git Bash
sh post receive
,它就可以工作了。但问题是脚本似乎没有触发。我也遇到了同样的问题-然后实现了,因为我的远程repo添加了一个文件系统路径(\\server\path),远程上的挂钩没有在远程计算机上执行。正在研究如何设置远程git服务器。
#!/bin/sh
echo "Starting copy from repository to work tree..."
pwd
hostname
git --work-tree=//remotehost/d$/Webseiten/__gitweb --git-dir=//remotehost/d$/_gitr
epo.git checkout -f
echo "Finished."