Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

msysgit error with hooks: "git error: cannot spawn .git/hooks/post-commit: No such file or directory"

I'm having trouble getting post-recieve and post-commit hooks to work correctly with msysgit (Windows 7 Pro/32 and Ultimate/64). For post-commit hook I get the above error if I commit from either git-bash or the console, but it works fine if I commit through git-gui. For a post-recieve hook, all three give the same error.

I'm thinking this is some sort of permission or path error, but don't really have any clue where to start here.

like image 575
Matt Avatar asked Apr 17 '11 23:04

Matt


People also ask

How do I make a git hook executable?

Open a terminal window by using option + T in GitKraken Client. Once the terminal windows is open, change directory to . git/hooks . Then use the command chmod +x pre-commit to make the pre-commit file executable.


1 Answers

Add the SHEBANG to the first line of hook, like so:

#!/bin/sh echo "executing post-commit" exit 0 

This had me stumped for a while as well and I saw that adding the shebang fixed it. In SVN world, while in *nix we have a "pre-commit" script and in Windows we had "pre-commit.bat" and SVN automatically picked up the bat file in Windows. Git doesn't seem to pick up a pre-commit.bat ( or any hook ) and adding the shebang to the hook file worked.

like image 75
manojlds Avatar answered Sep 27 '22 19:09

manojlds