githook验证新创建的分支名称 [英] githook to validate newly created branch names

查看:191
本文介绍了githook验证新创建的分支名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道是否有一个githook会挂接到分支的创建中,以便在分支名称实际创建之前就将其拒绝?

Does anyone know if there's a githook that will hook into the creation of a branch in order to reject the branch name before it's actually created?

我目前正在使用commit-msg在提交时验证分支名称,但是我正在寻找一种方法,避免在不符合我们的策略(正则表达式)的情况下必须重命名分支.

I currently use commit-msg to validate the branch name upon commits, but i'm looking for a way to avoid having to rename a branch if it doesn't match our policy (regex).

推荐答案

没有(在某种程度上是无法控制的:分支名称是在获取和推送期间通过refspecs在网络上传输的,而refspecs是有所限制).

There is not (and to some extent it can't be controlled: branch names are transferred across the network during fetch and push, via refspecs, and refspecs are somewhat limited).

个git命令,git check-ref-format;其文档描述了什么 Git 允许. (分支名称只是任何以refs/heads/开头的引用.)

There is a git command, git check-ref-format; its documentation describes what Git allows. (Branch names are simply any reference that starts with refs/heads/.)

这篇关于githook验证新创建的分支名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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