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.
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 whoami
or id -un
to 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.secondary
and post-update.secondary
hooks, which will have the GL_USER
environment variable set to the current Gitolite user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With