I
I
ImVeryStupid2020-07-08 11:50:07
git
ImVeryStupid, 2020-07-08 11:50:07

Cannot run hooks/post-receive: No such file or directory?

I'm trying to set up a quick php deployment from a local PC to a remote server using git hooks from this article .
There it is proposed to add a post-receive file with the content

#!/bin/bash
TARGET="/home/webuser/deploy-folder"
GIT_DIR="/home/webuser/www.git"
BRANCH="master"

while read oldrev newrev ref
do
    # only checking out the master (or whatever branch you would like to deploy)
    if [ "$ref" = "refs/heads/$BRANCH" ];
    then
        echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
        git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH
    else
        echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
    fi
done

to the hooks folder of the bare repository on the remote server.

It seems that I did everything right,
up to chmod 777 post-receive
but when I push on the local - I get:
fatal: cannot run hooks/post-receive: No such file or directory


and if you replace the line in the file
if [ "$ref" = "refs/heads/$BRANCH" ];
with
if [ "refs/heads/master" = "refs/heads/$BRANCH" ];
and execute the file in the remote console, then everything unfolds as it should and where it should.

So what changes when pushing from a local PC?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ImVeryStupid, 2020-07-08
@ImVeryStupid

deleted the line
#!/bin/bash
and away we go.
so and to go or it is fraught?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question