17

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...

1
  • Check if this helps. Commented Feb 6, 2012 at 11:29

1 Answer 1

25

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.

Sign up to request clarification or add additional context in comments.

9 Comments

Ok now so I ran website.git/hooks/post-receive and got "line 1: GET_WORK_TREE: command not found" :-/
D'oh I found out what was wrong: it should be GIT_WORK_TREE of course not GET_WORK_TREE
What does the MARK syntax do? I've been unable to find any docs on it. Thanks!
@Xgongiveittoya the MARK thing works with the << operator and is called a "here document". It's not part of Git, it's part of the shell. It's a way to send a file into a pipeline without first creating a file on disk. ss64.com/bash/syntax-here.html
@WinstonSmith first part sounds like you were looking at a bare repository. Second idk, but may indeed be on account of having just one commit.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.