我怎样才能手动运行钩子post-receive在git上? [英] How can I manually run the hook post-receive on git?

查看:219
本文介绍了我怎样才能手动运行钩子post-receive在git上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过Git将一个网站推送到了我的远程服务器,但遇到了错误

I've pushed a website to my remote server via Git but got the error

cannot run post-receive: No such file or directory

所以这些东西在服务器上,它没有被部署到我的/公用文件夹。

So the stuff is on the server, it has just not been deployed to my /public folder.

我确实有一个post-receive文件,所以我不知道为什么找不到。现在我认为我需要做的就是手动运行这个post-receive钩子来完成结账,但我不知道该怎么做......

I do however have a post-receive file so I am not sure why it was not found. Now I thought all I need to do is manually run this post-receive hook to do the checkout though I don't know how...

推荐答案

一个hook是一个可执行的shell脚本。如果你需要手工运行它,你可以从命令行执行它,但是如果你的仓库有不止一个头(这就是构造预期的 stdin inuput) ,你使用分支机构)。应该有一个低级别的命令来为你做这件事,但我不知道这个副手。

A hook is an executable shell script. You can execute it from the command line if you need to run it by hand, although constructing the expected stdin inuput is somewhat tedious if your repo has more than one head (that is, you use branches). There should be a low-level command to do this for you, but I don't know this offhand.

假设你的git回购中有一个bash shell和一个分支...

Assuming a bash shell and a single branch in your git repo...

# Print the log with full hashes and commit subject, so that you can
# figure out which hashes to use for the FROM and TO range.
/path/to/repo$ git log --pretty=%H\ %s

# assuming the FROM commit identifies as 999988887777
# and te TO commit identifies as 000011112222
# (Note: use the full length hashes; I've shortened them for the example)
/path/to/repo$ .git/hooks/post-receive <<MARK
999988887777 000011112222 refs/heads/master
MARK

...上面应该可以工作就像真实的东西一样。

...the above should work just like the real thing.

这篇关于我怎样才能手动运行钩子post-receive在git上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆