【问题标题】:How can I manually run the hook post-receive on git?如何在 git 上手动运行钩子 post-receive?
【发布时间】:2012-02-06 11:16:18
【问题描述】:

我已通过 Git 将网站推送到远程服务器,但出现错误

cannot run post-receive: No such file or directory

所以这些东西在服务器上,只是没有部署到我的 /public 文件夹中。

但是我确实有一个接收后文件,所以我不确定为什么找不到它。现在我想我需要做的就是手动运行这个 post-receive 挂钩来进行结帐,虽然我不知道如何......

【问题讨论】:

  • 检查this是否有帮助。

标签: git


【解决方案1】:

钩子是一个可执行的 shell 脚本。如果您需要手动运行它,您可以从命令行执行它,但如果您的 repo 有多个头(即,您使用分支),则构建预期的 stdin inuput 有点乏味。应该有一个低级命令来为您执行此操作,但我不知道这一点。

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

# 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

...上面的内容应该和真实的一样。

【讨论】:

  • 好的,所以我运行了 website.git/hooks/post-receive 并得到“第 1 行:GET_WORK_TREE:找不到命令”:-/
  • D'oh 我发现了问题所在:应该是 GIT_WORK_TREE 当然不是 GET_WORK_TREE
  • MARK 语法有什么作用?我一直找不到关于它的任何文档。谢谢!
  • @Xgongiveittoya MARK 东西与&lt;&lt; 运算符一起使用,被称为“此处文档”。它不是 Git 的一部分,而是 shell 的一部分。这是一种无需先在磁盘上创建文件即可将文件发送到管道的方法。 ss64.com/bash/syntax-here.html
  • @Barend 太棒了,谢谢!我不知道该用谷歌搜索什么。
猜你喜欢
  • 2012-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-02
  • 2017-10-19
  • 2010-11-24
  • 2014-05-13
  • 2014-10-28
相关资源
最近更新 更多