Git站点部署 - post-receive hook中的checkout无效

oky*_*net 0 git repository git-checkout git-post-receive

我已经按照本教程"使用Git管理网站",使用Tower提交并将我的本地存储推送到远程服务器.通过以下消息推送成功:

Pushing to ssh://user@mysite.com/~/git/tprevo.git
stdin: is not a tty
Counting objects: 40, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (37/37), done.
Writing objects: 100% (40/40), 171.95 KiB, done.
Total 40 (delta 3), reused 0 (delta 0)
To ssh://user@mysite.com/~/git/tprevo.git
 * [new branch]      master -> production
updating local tracking ref 'refs/remotes/production/production'

Successfully created tracking connection.
Run Code Online (Sandbox Code Playgroud)

我已经验证我的post-receive挂钩正在执行,但该checkout命令没有将推送的代码添加到我认为我已设置为我的工作目录的内容中.我一直试图弄清楚这一点.

后得到:

#!/bin/sh
GIT_WORK_TREE=/home/tprevo/public_html/tprevo git checkout -f
Run Code Online (Sandbox Code Playgroud)

我是Git的新手,非常热衷于学习.调试这个的最佳方法是什么?

Edd*_*e B 7

好的......我有类似的设置......你的文件可执行吗?请检查文件属性...

ls -la post-receive
Run Code Online (Sandbox Code Playgroud)

如果它不可执行,那么你需要chmod它...

sudo chmod +x post-receive
Run Code Online (Sandbox Code Playgroud)

UPDATE

注意到你有一个命名分支,你可能希望在checkout命令中具体为你的post-receive钩子...

git checkout -f production
Run Code Online (Sandbox Code Playgroud)