Ram*_*ndo 12 windows git hook post
我有以下代码在hook post-receive的工作目录中签出:
#!/bin/sh
git --work-tree=d:/websites/__gitweb --git-dir=d:/_gitrepo.git/ checkout -f
Run Code Online (Sandbox Code Playgroud)
不幸的是它似乎不起作用.但是,当我在Windows命令行(cms)中输入此命令时,该命令可以正常工作:
git --work-tree=d:/websites/__gitweb --git-dir=d:/_gitrepo.git/ checkout -f
Run Code Online (Sandbox Code Playgroud)
我检查了权限和执行属性,但没有.
更新:
我想我越来越近了.现在我知道问题是什么,但我不知道为什么会这样.挂钩实际上是被触发但我收到此消息:
remote: Starting copy from repository to work tree...
remote: fatal: Not a git repository: 'd:/_gitrepo.git/'
remote: Finished.
Run Code Online (Sandbox Code Playgroud)
我试图将d:的路径改为整个网络路径,但它仍然无效.如果我去远程存储库并且我做了一个git日志,那么更改就在那里,如果我用sh运行钩子,它就可以了.为什么说它显然不是git存储库?
Ram*_*ndo 14
我终于搞定了!这真的很奇怪.我必须键入a 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."
Run Code Online (Sandbox Code Playgroud)
我希望这个解决方案适合某人