Git hook: enable echoing commands

空扰寡人 提交于 2019-12-19 17:35:11

问题


is there any way to enable echo in 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

desired git push output on another mashine:

#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

this is just an example, actual command chain can be more complicated

and fail somewhere

should I redirect stdout to stderr somehow?

UPDATE

currently I have normal git push output and then ========post-update hook========= ... and nothing

Oh! git version is 1.5.6.5


回答1:


All output on either stdout or stderr should be forwarded. It's expected to work for all of pre-receive, update, post-receive and post-update hooks. Echoing commands is enabled with set -x in bourne shell.




回答2:


From githooks manual:

Both standard output and standard error output are forwarded to git send-pack on the other end, so you can simply echo messages for the user.

But there was a know issue in some earlier versions of Git and also earlier version of Smart HTTP, whereby the output was not send. Update your git version and try.



来源:https://stackoverflow.com/questions/7266772/git-hook-enable-echoing-commands

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!