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

I am trying to configure 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 click on my local repository, I see this echo message, the script is called correctly.

But the check does not start! There is an error in the 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!

+6
source share
2 answers

From the comments:

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

work.

However, a comment by OP RobertM :

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

This is another problem and can be solved, for example, using the disk naming convention: you can decide how the path of the remote repo ( d:\test or any other path) to a specific drive letter ( X: for example), the Windows subst command .

+2
source

I have mysysgit running on a web server that I click from my local workstation and I use the following post-reception script:

 #!/bin/sh git --work-tree=/cygdrive/d/www --git-dir=/cygdrive/d/CodeRepositories/tempRepo.git checkout -f 

What made me first indicate that the file is not in UNIX format, you can use Notepad ++ to change it. Please note: I am using cygwin to click on SSH, so your directory names can be changed.

0
source

Source: https://habr.com/ru/post/901881/


All Articles