【FAQ】如何部署全局git commit-msg hook,不用每个仓克隆了再去一次次拷贝?

来源:互联网 发布:数据库删除多条数据 编辑:程序博客网 时间:2024/06/13 02:36

问题:

git和gerrit对接,git commit的时候都提示“missing Change-Id in commit message footer”。知道是因为change-id搞的鬼,也知道从gerrit上或者其他地方拷个commit-msg脚本儿,放到.git/hooks目录下就完事儿了。但是,每次重新克隆时,就有得再来一遍拷贝动作,很低效。

注:

单仓拷贝,不用repo。

方法:

部署本地全局Hook即可:

$mkdir -p ~/.git_template/hooks
$cp commit-msg ~/.git_template/hooks
$git config --global init.templatedir ~/.git_template

参考:
http://git-scm.com/docs/git-config.html

https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration

1 0