How to write Git Server Hooks on Windows platform?

2019-06-21 21:05发布

问题:

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?

回答1:

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"