I have a gitolite server and I would like to setup a server-side hook so that when anyone clones a repository located on it, an email is sent out to the administrator. Right now seems that is only able to do it for push but not for cloning.. Was I wrong?
There is no server-side fetch hook from git. gitolite has PRE_GIT
and POST_GIT
triggers which you can use to detect when someone is fetching (running git-upload-pack
) but the difference between a clone and a normal fetch is a human semantics one.
The only way to detect what may be a clone is way inside the protocol layer if the client doesn't provide any local commits in the negotiation, but it could still just be someone running fetch manually.
Lastly, as git is distributed, cloning from your server or cloning from elsewhere (maybe a coworker's computer/usb stick or a different repo in the same computer) and then fetching the rest from the server is essentially the same, as there is no strong binding between repositories.