Git 钩子(Hook) : enable echoing commands

标签 git githooks

有没有办法在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

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

某处失败

我应该以某种方式将 stdout 重定向到 stderr 吗?

更新

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

哦! git 版本是 1.5.6.5

最佳答案

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

关于Git 钩子(Hook) : enable echoing commands,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7266772/

相关文章:

php - git post-receive 钩子(Hook)在 php 中

android - 缺少获取 android.compileSdkVersion !错误梯度构建

git - 你如何找出这样一个工作流程中的前一个标签?

git - 如何从预接收 Hook 中获取我的分支名称?

git hooks - 重新生成一个文件并将其添加到每个提交?

regex - 获取 Windows 上 Git Hook 的 %AppData% 路径(或其他环境变量)(10)

git - 在 VSO 或 VS2015 中创建 Git 分支标签

git - 显示 'git anycommand -h'命令的所有信息

git - 为什么 GitLab 自上次 merge 以来没有提交到目标分支时会说存在冲突?

git - 跨平台 git 钩子(Hook)