Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

post-receive hook on Windows - GIT_WORK_DIR: no such file or directory

Tags:

git

I try to setup my post-receive hook on git (windows). Here is the script:

#!/bin/sh
echo "post-receive hook"
GIT_WORK_TREE=/d/test git checkout -f

When I do git push on my local repository I see this echo message, script is called properly.

But the checkout doesn't run! There is an error in console view:

remote: fatal: Could not switch to '/d': No such file or directory

But when I put this command in Git Bash, it works!

like image 661
RobertM Avatar asked Nov 19 '11 11:11

RobertM


1 Answers

From the comments:

GIT_WORK_TREE=/Volumes/D/test git checkout -f

works.

However, the OP RobertM comments:

What if I will push from another computer? I have other clone on my windows machine where this path is not available

That is a different issue, and can be solve for instance with a drive naming convention: one can decide to associate whatever path the remote repo is (d:\test or any other path) to a specific drive letter (X: for instance), with the Windows subst command.

like image 89
VonC Avatar answered Nov 13 '22 01:11

VonC