Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I manually run the hook post-receive on git?

Tags:

git

I've pushed a website to my remote server via Git but got the error

cannot run post-receive: No such file or directory

So the stuff is on the server, it has just not been deployed to my /public folder.

I do however have a post-receive file so I am not sure why it was not found. Now I thought all I need to do is manually run this post-receive hook to do the checkout though I don't know how...

like image 442
nerdess Avatar asked Feb 06 '12 11:02

nerdess


1 Answers

A hook is an executable shell script. You can execute it from the command line if you need to run it by hand, although constructing the expected stdin inuput is somewhat tedious if your repo has more than one head (that is, you use branches). There should be a low-level command to do this for you, but I don't know this offhand.

Assuming a bash shell and a single branch in your git repo...

# Print the log with full hashes and commit subject, so that you can
# figure out which hashes to use for the FROM and TO range.
/path/to/repo$ git log --pretty=%H\ %s

# assuming the FROM commit identifies as 999988887777
# and te TO commit identifies as 000011112222
# (Note: use the full length hashes; I've shortened them for the example)
/path/to/repo$ .git/hooks/post-receive <<MARK
999988887777 000011112222 refs/heads/master
MARK

...the above should work just like the real thing.

like image 54
Barend Avatar answered Sep 21 '22 16:09

Barend