Git site deployment - checkout in post-receive hook not working

自古美人都是妖i 提交于 2019-12-08 11:45:09

问题


I've followed this tutorial 'Using Git to manage a web site', using Tower to commit and push my local repo to the remote server. Pushing succeeds with the following message:

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.

I've verified that my post-receive hook is executing, but the checkout command doesn't add the pushed code into what I believe I've set up as my working directory. I've been trying to figure this out all day.

post-receive:

#!/bin/sh
GIT_WORK_TREE=/home/tprevo/public_html/tprevo git checkout -f

I'm new to Git and very keen to learn. What's the best way to debug this?


回答1:


Okay ... I've got a similar setup ... is your file executable? Please check the files attributes ...

ls -la post-receive

If it's not executable then you need to chmod it ...

sudo chmod +x post-receive

UPDATE

Noticing that you have a named branch you may want to be specific in the checkout command for your post-receive hook ...

git checkout -f production


来源:https://stackoverflow.com/questions/11121321/git-site-deployment-checkout-in-post-receive-hook-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!