【问题标题】:Git hook: enable echoing commandsGit钩子:启用回显命令
【发布时间】:2011-11-08 04:02:25
【问题描述】:

有没有办法在 git hook 中启用回显

/var/git/repositories/project.git/hooks/post-update

#!/bin/bash
unset GIT_DIR;
echo '========post-update hook========='

cd /var/project;
git reset --hard;
git checkout testing;
git pull;
chmod -R 774 ./lib

update-apps

期望的 git push 输出到另一个机器上:

#git push
...
Writing objects: 100% (10/10), 5.98 KiB, done.
Total 10 (delta 3), reused 8 (delta 1)
========post-update hook=========
cd /var/project
git reset --hard
git checkout testing
git pull
chmod -R 774 ./lib
update-apps

这只是一个例子,实际的命令链可能更复杂

在某处失败

我应该以某种方式将标准输出重定向到标准错误吗?

更新

目前我有正常的git push 输出,然后是========post-update hook========= ...什么都没有

哦! git版本是1.5.6.5

【问题讨论】:

  • 但是当你尝试时你的实际输出是什么?
  • 检查钩子是否可执行(chmod +x)

标签: git githooks


【解决方案1】:

应转发 stdout 或 stderr 上的所有输出。它预计适用于所有 pre-receiveupdatepost-receivepost-update 钩子。在 bourne shell 中使用 set -x 启用回显命令。

【讨论】:

    【解决方案2】:

    来自githooks手册:

    标准输出和标准错误输出都转发给git send-pack 在另一端,因此您可以简单地回显消息 用户。

    但是在一些早期版本的 Git 和早期版本的 Smart HTTP 中存在一个已知问题,即未发送输出。更新您的 git 版本并尝试。

    【讨论】:

      猜你喜欢
      • 2020-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-23
      • 2020-03-11
      • 1970-01-01
      相关资源
      最近更新 更多