git:谁在推送后接收钩子 [英] git: who pushed in post-receive hook

查看:156
本文介绍了git:谁在推送后接收钩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何确定谁推送到存储库?

有人会在 origin repo的post-receive钩子中使用 git push origin master 如果您使用SSH协议将更改推送到服务器,每个用户都有他们自己的帐户在服务器上,那么您的脚本应该以正在进行推送的用户身份运行。因此,您应该可以使用 whoami id -un 获取推送人员的用户名。



如果您不使用此设置,跟踪推送人员的最佳方式可能是使用,一个功能强大的Git身份验证和授权系统。在Gitolite中,您可以使用 update.secondary post-update.secondary 钩子,它将把 GL_USER 环境变量设置为当前的Gitolite用户。

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.

这篇关于git:谁在推送后接收钩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆