Git post-receive hook fails because it can't remove temp directory

Viewed 15

I'm writing a simple Git receive hook that does the following:

git clone $GIT_REPO $TMP_GIT_CLONE
pushd $TMP_GIT_CLONE
npm install
... other things
popd
rm -rf $TMP_GIT_CLONE
exit

However, my hook will always fail on the next push:

remote: fatal: destination path '/home/private//tmp/LOGEYIO' already exists and is not an empty directory.

because I'm unable to remove the temporary folder in the post-receive hook:

remote: /home/private/git/LOGEYIO.git
remote: rm: /home/private//tmp/LOGEYIO/.git/objects/pack: Directory not empty
remote: rm: /home/private//tmp/LOGEYIO/.git/objects: Directory not empty
remote: rm: /home/private//tmp/LOGEYIO/.git: Directory not empty
remote: rm: /home/private//tmp/LOGEYIO: Directory not empty
To ssh://ssh.phx.nearlyfreespeech.net/home/private/git/LOGEYIO.git

Am I trying to remove this temp folder wrong? Is there a way to force it to be deleted?

0 Answers
Related