5

I can't find any clear examples of Git hooks for Windows. I use Bonobo Git Server on Windows Server. I need pre-commit and post-commit hooks as cmd or bat. Pre-commit should check empty comments and post-commit should send an e-mail notification about commit. May be somebody has similar hooks and ready to share?

JMLabs
  • 61
  • 2
  • Hooks are not restricted to bash / cmd / powershell. You can use any language you want, just make sure they can be executed on server platform. I was pretty successful at writing hooks on Groovy on Windows. Just need to configure MIME types (also, don't forget about shebangs, they'll make you scripts more portable). – madhead Apr 08 '15 at 20:57

1 Answers1

3

After some experimenting I found out that

#!/Git/sh

echo This is the receive-hook >> result.txt

in

C:\inetput\wwwroot\Bonobo.Git.Server\App_Data\Repository\<your repository>\hooks\receive-hook

Was executed on a remote

git push

Then you can call a batch like

#!/Git/sh

cmd //C "post-receive.cmd"
Marijn Deé
  • 886
  • 2
  • 13
  • 21
  • Do I understand you correctly? Do you have two files - receive-hook and post-receive.cmd and receive-hook is automatically executed on git push and it executes post-receive.cmd? I tried the same, but it did not work for me. No idea what I am doing wrong... – Michal B. May 05 '17 at 12:18
  • I have tried the same too, with variants on file namings, but I could not get it triggered. I placed the file `post-receive.cmd` in the repository subdirectory `hooks` (its luck folder did exists already by default) so the path is `"C:\inetpub\Git\SuperRepository1\hooks\post-receive.cmd"` When I commit on a branch and push, it does not trigger the cmd file. – Nasenbaer Feb 10 '23 at 14:11