git中预推送和预接收钩子之间的区别? [英] Difference between pre-push and pre-receive hook in git?

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

问题描述

git中的pre-push和pre-receive hook在用例或工作逻辑方面有区别吗?

我可以从他们的文档根据他们收到的输入信息 -



1. 预推送:在钩子的标准输入上提供有关要推送什么的信息,其格式为 local ref SP local sha1 SP remote ref SP遥控器sha1 LF


$ b 2. 预接收:对于每个要更新的参考点,的格式 -

旧值SP新值SP ref-name LF

但是,我想知道是否有特定的用例对于每个钩子或可以互换使用?

解决方案

一个( pre-push )是 客户端钩子,另一个( pre-receive )是一个 <服务器端挂钩



在这方面,它们非常不同,如果你想为了一致地执行给定的策略,你经常在预接收(服务器端)钩子中执行它。这样,您不必担心在每个客户端上部署预推钩。



请记住:钩子 local 回购 ,这意味着预推钩不容易分发到任何 下游回购 。但是如果这些下游回购都是指相同的上游回购,则预接收挂钩可以适用于他们。


Is there a difference between pre-push and pre-receive hook in git, in terms of use case or working logic?
The only difference I could understand from their documentation was in terms of the input they receive -

1.Pre-Push : Information about what is to be pushed is provided on the hook's standard input with lines of the form - local ref SP local sha1 SP remote ref SP remote sha1 LF

2.Pre-receive : For each ref to be updated it receives on standard input a line of the format -
old-value SP new-value SP ref-name LF
However, I would like to know if there are particular use cases for each hook or can they be used interchangeably?

解决方案

One (pre-push) is a client-side hook, the other (pre-receive) is a server-side hook.

In that aspect, they are very different, and if you want to enforce consistently a given policy, you often do it in a pre-receive (server side) hook. That way, you don't have to worry about deploying a pre-push hook on each client.

Remember: hooks are local to a repo, which means a pre-push hook cannot easily be distributed to any downstream repo. But if those downstream repos are all referring to the same upstream repo, a pre-receive hook can apply to them all.

这篇关于git中预推送和预接收钩子之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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