How create right git hook in PhpStorm on PHP?

If add git hook to pre-commit with following code then you get error “Error!” in PHPStorm.

#!/usr/bin/sh
echo "Error!"
exit 1

But if implement this on PHP you cannot get this error message in PHPStorm.

  • How can I view branches other than master in gitweb?
  • Coloring white space in git-diff's output
  • What to do with Github branches that have been merged to upstream?
  • Is there a way to have a patch that is never commited, only changes the working copy?
  • Web access HTML file in my Gitlab repo
  • Abort a git cherry-pick?
  • #!/usr/bin/php
    <?php
    echo "Error!";
    exit(1);
    

    PHPStorm return not understandable error:

    error: cannot spawn .git/hooks/pre-commit: No such file or directory

    Any ideas how to resolve this problem?

    P.S. In command prompt all is ok.

  • git rebase resolve conflicts again and again?
  • How to rename large number of files
  • Understanding symfony2 deps
  • How do you handle Doctrine Migrations when using Git?
  • Installing git on a cPanel server
  • Why shouldn't I push a virtualenv to Heroku?
  • One Solution collect form web for “How create right git hook in PhpStorm on PHP?”

    If php.exe is in your %PATH%, you can ask for the shebang to look for it:

    #! /usr/bin/env php.exe 
    
    Git Baby is a git and github fan, let's start git clone.