8

有什么方法可以在 git hook 中启用 echo

/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

4

2 回答 2

4

应转发 stdout 或 stderr 上的所有输出。预计它适用于所有,pre-receiveupdatehooks 。在 bourne shell中启用了回显命令。post-receivepost-updateset -x

于 2011-09-01T06:45:06.067 回答
2

githooks手册:

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

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

于 2011-09-01T06:51:35.887 回答