小编Nom*_*g25的帖子

Git - post-receive没有在windows上运行

我在Windows Server 2008 R2上运行XAMPP服务器.我正在运行Git 64bit版本2.16.1.windows.1我想post-receive在我从客户端进行推送后使用hook来更新我的网站.

MyProject.git在服务器上创建了一个裸项目并将其克隆到MyProject.

我的钩子是:

#!C:/Program\ Files/Git/usr/bin/sh.exe 
echo "Hook got triggered.." > hooks.txt
exec powershell.exe -NoProfile -ExecutionPolicy Bypass -File ".\hooks\post-receive.ps1"
Run Code Online (Sandbox Code Playgroud)

Powershell脚本是:

cd "C:/xampp/htdocs/webapp/myProject/"
git pull origin master
exec git-update-server-info
Run Code Online (Sandbox Code Playgroud)

我搜索了类似的问题而没有任何运气来解决问题.

如果我在powershell中手动运行脚本,它运行正常.根据我的日志,钩子甚至开火.

Apache上的Git看起来配置正确,因为我可以毫无问题地推送到远程,如果我在MyProject文件夹中对服务器进行拉动,我从repo获得的文件是正确的.

我错过了什么?

编辑:

我修好了我的钩子:

#!C:/Program\ Files/Git/usr/bin/sh.exe
echo "Hook got triggered.."
exec powershell.exe -NoProfile -ExecutionPolicy Bypass -File ".\hooks\post-receive.ps1"
Run Code Online (Sandbox Code Playgroud)

我的powershell脚本:

cd "C:/xampp/htdocs/webapp/myProject/"
unset GIT_DIR
git pull origin master
exec git-update-server-info
Run Code Online (Sandbox Code Playgroud)

我推送到远程时的响应是:

Counting objects: 3, done.
Delta compression using up to 8 …
Run Code Online (Sandbox Code Playgroud)

windows apache git

7
推荐指数
1
解决办法
451
查看次数

标签 统计

apache ×1

git ×1

windows ×1