简体   繁体   English

GIT-获取推送的分支名称,服务器端

[英]GIT - Get pushed branch name , server side

I have a git repository and i want to launch an hook when someone is trying to push on a specific branch. 我有一个git信息库,当有人尝试推送特定分支时,我想启动一个钩子。 ( pre-receive hook, check branch, refuse if it's master branch. ) pre-receive钩子,检查分支,如果它是主分支则拒绝。)

Is there any variables where i can get pushed branch on server side when users, on his $git clone use $git push ? 当用户在他的$git clone使用$git push时,是否有任何变量可以在服务器端推送分支?

Thanks. 谢谢。

Due to the structure of git, you will be aware of user changes first, when the user pushes its changes to the remote. 由于git的结构,当用户将其更改推送到远程时,您将首先意识到用户的更改。 So the only way to safely handle this condition is using server-side-hooks . 因此,安全处理此情况的唯一方法是使用服务器端挂钩

The client-side-hooks reside in a hidden folder of your repository, so you have unfortunately no control over it. 客户端挂钩位于存储库的隐藏文件夹中,因此很遗憾,您无法对其进行控制。

A nearly similar question was asked once before. 曾经有人问过一个几乎相似的问题

You are able to act on updates on different branches (refs) by using the update -script . 您可以使用update -script在不同分支(引用)上执行update

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM