Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git hook: enable echoing commands

Tags:

git

githooks

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

like image 263
jonny Avatar asked Sep 01 '11 06:09

jonny


1 Answers

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.

like image 64
Jan Hudec Avatar answered Nov 10 '22 12:11

Jan Hudec