I am looking to monitor the cloning activity within my git repository however I cannot find anything that shows how to set this up or how to retrieve this information.
Is this even possible? If so how can this be setup and also how do you retrieve the logging information?
I was going to post the same question but find this one out. The better that I could find is wrapping the
git-upload-pack
command to log the call. This will only work over ssh though see: pre-fetch hook functionality in gitBut only root will be able to do this. It doesn't work for me, but perhaps it's a solution for others.
You may always install a "git server" for controlling access like gitolite (http://sitaramc.github.com/gitolite/master-toc.html). Either you can log it directly or you can extend it's functionality.
I don't think that there is any hook or something similar that runs in the server side of the repository on a clone. git probably just uses the specified protocol (ssh,http,...) and fetches the appropriate files. You could try to monitor that activity somehow.
You can use a
post-checkout
hook to update a database or file on your server. This hook runs on the client-side (that is, the person doing the clone will execute the script), so you need to design your script from that perspective. Also, it is possible to clone the repository without executing this hook by adding the--no-checkout
option togit clone
.A simple and reliable approach would be to have the server running a small RESTful web service that your hook can call with
curl
or some similar facility. For example:See http://www.kernel.org/pub/software/scm/git/docs/githooks.html.