It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Read echos from hooks / manage hooks

Hello guys.


I'm quite new with git hooks, so sorry if my question sounds dumb.


I've got a bare repo on my server, and I've set up a post-receive hook to automatically checkout the bare repo to my production directory.  Then, in ST, I've set up a remote that writes to the bare repo.

This is the hook:

while read oldrev newrev ref
if [[ $ref =~ .*/master$ ]];
echo "Master ref received. Deploying master branch to production..."
git --work-tree=[prod_dir] --git-dir=[repo_dir] checkout -f
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."

[prod_dir] and [repo_dir] are correctly set to the directories for the production and the bare repo.

Everything was working good, until I started to change the hook, specifically I added the command for composer to update just under the git command. I performed a push, and the checkout didn't work out (my production directory was not updated).

I then read online that I should place any other command right under the `done`. 


Now, I've got a two questions:

1) Is there a way to get the echos from the hook directly in output of ST?

2) Is the post-receive hook triggered if the bare repo is already updated? Because after my first push (that failed) I started to edit the hook in order to test if something was wrong in there, and I kept pushing (ofcourse nothing changed in the files so the status was [up to date]). I tried to do some random stuff, such as echoing "hello" into a file, but nothing happened. I suspect that when everything is up to date, the hook is not triggered.


Thank you!

1 answer

0 votes
Mike Corsaro Atlassian Team Feb 27, 2018


  1. All "echos" will output in the output in Sourcetree. To ensure you even see that output, make sure "Tools > Options > General > Always display full console output" is checked. You should then see the output from the hook
  2. That's a git-specific question, but if I had to guess it probably won't do anything if there isn't anything to push. You could commit using "--allow-empty" though, and then push (you'll need to do that via command-line as Sourcetree doesn't have a setting for that though)

Thank you for your suggestion.

I've activated the 'Always display...' (was in the advanced tab).


I'm pretty sure that the echos were not shown tho, I'll have to verify on my next commit.


In the meanwhile, thank you.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Sourcetree

Sourcetree for Windows - CVE-2019-11582 - Remote Code Execution vulnerability

A vulnerability has been published today in regards to Sourcetree for Windows.  The goal of this article is to give you a summary of information we have gathered from Atlassian Community as a st...

4,935 views 0 12
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you