How do I determine who pushed to the repository?
I.e. Somebody does git push origin master and in the post-receive hook on the origin repo I need to use the name or e-mail of Somebody.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re using the SSH protocol to push changes to the server, with each user having their own account on the server, then your script should be running as the user who’s doing the push. So, you should be able to use
whoamiorid -unto get the username of the person doing the push.If you are not using this setup, the best way to keep track of who is pushing is probably using Gitolite, a powerful Git authentication and authorization system. In Gitolite, you can use the
update.secondaryandpost-update.secondaryhooks, which will have theGL_USERenvironment variable set to the current Gitolite user.