Git Hook under Windows
#!/bin/sh git --work-tree=d:/websites/__gitweb --git-dir=d:/_gitrepo.git/ checkout -f
Unfortunately it doesn’t seem to work. However, the command does work when I enter just this in the windows command line (cms):
- assertion failed errors when trying to git subtree split
- Authenticating users in git with LDAP
- pre-push hook is reporting that git-lfs is not in my path, but it is
- Let git bash launch at current repositories
- Git Bash won't run my python files?
- With the win git the git variable is not in the enironment_variables anymore, how to open the Git Shell and run commands from there?
git --work-tree=d:/websites/__gitweb --git-dir=d:/_gitrepo.git/ checkout -f
I have checked the permissions and the executing attributes but nothing.
I think I’m getting closer. Now I know what the problem is but I don’t know why is this happening. The hook is actually being triggered but I receive this message:
remote: Starting copy from repository to work tree... remote: fatal: Not a git repository: 'd:/_gitrepo.git/' remote: Finished.
I have tried to change the path of d: to the whole network path but it still doesn’t work. If I go to the remote repository and I do a git log, the changes are there and if I run the hook with sh, it works.
Why is it saying that it is not a git repository when clearly it is?
2 Solutions collect form web for “Git Hook under Windows”
I finally got it working!
This is really weird. I had to type a
pwd to see where actually is the batch being located and it showed the hook location on the server. However, in the next line I added a
hostname and it showed me my local hostname.
Then I add the whole path just like:
#!/bin/sh echo "Starting copy from repository to work tree..." pwd hostname git --work-tree=//remotehost/d$/Webseiten/__gitweb --git-dir=//remotehost/d$/_gitr epo.git checkout -f echo "Finished."
I hope this solution works for someone
For a shell script (and those hook scripts will be executed as shell, even in Windows, through the msys layer of msysgit), you could use a different sort of path:
#!/bin/sh git --work-tree=/d/websites/__gitweb --git-dir=/d/_gitrepo.git/ checkout -f
See also other possibilities with “Posix path conversion in MinGW”