gpt4 book ai didi

git - 在 git 中强制执行提交消息格式

转载 作者:太空狗 更新时间:2023-10-29 12:43:31 25 4
gpt4 key购买 nike

我如何才能在 Git 中强制执行提交消息格式?

这是否可以在存储库级别进行设置,以便创建分支的每个人都可以执行此操作?

最佳答案

如 Git ProBook“Customizing Git - An Example Git-Enforced Policy”中所述,此类强制执行将通过 Hook 设置,更具体地说,服务器端 Hook ,如 更新一个:

All the server-side work will go into the update file in your hooks directory. The update hook runs once per branch being pushed and takes three arguments:

  • The name of the reference being pushed to
  • The old revision where that branch was
  • The new revision being pushed

这优于客户端 Hook (如 pre-commit Hook ):

  • 必须由每个用户手动设置
  • 可以绕过

对于给定的 repo 协议(protocol),如果您的政策未得到遵守,服务器端 Hook 将通过拒绝 git 推送来强制执行您想要的任何规则。

这假设您可以控制您的用户推送到的远程存储库托管服务器。

如果不这样做,您将回到客户端预提交 Hook ,可以通过 git 模板进行设置,whose template directory can be shared amongst all users (starting with git 2.9, June 2016) .

关于git - 在 git 中强制执行提交消息格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37709643/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com