为 windows 编写 post 接收脚本
Writing a post receive script for windows
我目前正在使用 2012 年的 bonobo git 网络服务器。我想编写一个 post-recieve 挂钩,以便我可以将我的 repo 检查到我网站的活动目录中。
我这样声明我的 post-接收脚本
#!/bin/sh
GIT_WORK_TREE=C:/Domains/Demo.com git checkout -f
当我将更改推送到我的 git 服务器时,它现在应该将我的回购协议的内容检出到 Domains/Demo 文件夹中。在我更改了一个小东西并提交到网络服务器之后,我检查了 Demo.com 的目录,看是否有任何内容。可悲的是 none。有没有办法知道脚本是否为 运行?有没有更好的方法来解决这个问题?
您可以通过添加一些 echo
语句来测试您的 post-receive
钩子是否被执行。来自 githooks
documentation:
Both standard output and standard error output are forwarded to git send-pack
on the other end, so you can simply echo
messages for the user.
此外,我建议使用 --work-tree
选项而不是 GIT_WORKING_TREE
环境变量。脚本的修改版本如下所示:
#!/bin/sh
git --work-tree="C:/Domains/Demo.com" checkout -f
我目前正在使用 2012 年的 bonobo git 网络服务器。我想编写一个 post-recieve 挂钩,以便我可以将我的 repo 检查到我网站的活动目录中。 我这样声明我的 post-接收脚本
#!/bin/sh
GIT_WORK_TREE=C:/Domains/Demo.com git checkout -f
当我将更改推送到我的 git 服务器时,它现在应该将我的回购协议的内容检出到 Domains/Demo 文件夹中。在我更改了一个小东西并提交到网络服务器之后,我检查了 Demo.com 的目录,看是否有任何内容。可悲的是 none。有没有办法知道脚本是否为 运行?有没有更好的方法来解决这个问题?
您可以通过添加一些 echo
语句来测试您的 post-receive
钩子是否被执行。来自 githooks
documentation:
Both standard output and standard error output are forwarded to
git send-pack
on the other end, so you can simplyecho
messages for the user.
此外,我建议使用 --work-tree
选项而不是 GIT_WORKING_TREE
环境变量。脚本的修改版本如下所示:
#!/bin/sh
git --work-tree="C:/Domains/Demo.com" checkout -f