Git hook: enable echo commands

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 output to another computer:

 #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; a valid command chain can be more complex.

and crash somewhere

Should I redirect stdout to stderr?

UPDATE

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

ABOUT! git version 1.5.6.5

+6
source share
2 answers

All output on either stdout or stderr should be redirected. It is expected to work for all tracks pre-receive , update , post-receive and post-update . Echo commands are enabled using set -x in the bourne shell.

+3
source

From the githooks guide:

Both standard outputs and standard error output are sent to the gitsend-pack at the other end, so you can simply echo messages to the user.

But in some earlier versions of Git, the problem was known, as well as an earlier version of Smart HTTP, which resulted in no output being sent. Upgrade Git and try.

+2
source

Source: https://habr.com/ru/post/896379/


All Articles