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

时间:2022-07-03 23:43:44

I have a git repository and i want to launch an hook when someone is trying to push on a specific branch. ( pre-receive hook, check branch, refuse if it's master branch. )

我有一个git存储库,我想在有人试图推送特定分支时启动一个钩子。 (预先接收钩子,检查分支,如果它是主分支则拒绝。)

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.

谢谢。

1 个解决方案

#1


1  

Due to the structure of git, you will be aware of user changes first, when the user pushes its changes to the remote. So the only way to safely handle this condition is using server-side-hooks.

由于git的结构,当用户将其更改推送到远程时,您将首先了解用户更改。因此,安全处理此情况的唯一方法是使用服务器端挂钩。

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对不同分支(refs)上的更新进行操作。

#1


1  

Due to the structure of git, you will be aware of user changes first, when the user pushes its changes to the remote. So the only way to safely handle this condition is using server-side-hooks.

由于git的结构,当用户将其更改推送到远程时,您将首先了解用户更改。因此,安全处理此情况的唯一方法是使用服务器端挂钩。

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对不同分支(refs)上的更新进行操作。