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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With