在git钩子中获取提交消息 [英] get commit message in git hook

查看:958
本文介绍了在git钩子中获取提交消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在git commit之前检查提交消息。
我使用pre-commit钩子来做到这一点,但是找不到在.git / pre-commit脚本中获取提交信息的方式。
我怎么能得到它?

I would like to check commit message before git commit. I use pre-commit hook to do that, but couldn't find the way to get commit message in .git/pre-commit script. How could I get it?

推荐答案

在预提交钩子中,提交消息尚未创建然而。您可能希望使用 prepare-commit-msg commit-msg 钩子之一。订单中有 Pro Git中的精美版块哪些钩子运行,以及你通常可以用它们做什么。

In the pre-commit hook, the commit message hasn't been created yet. You probably want to use one of the prepare-commit-msg or commit-msg hooks instead. There's a nice section in Pro Git on the order in which these hooks are run, and what you typically might do with them.

这篇关于在git钩子中获取提交消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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