# Automatically placing Gerrit's commit-msg hook in every new git repository

DevFeed: [Automatically placing Gerrit's commit-msg hook in every new git repository](<https://devfeed.tech/articles/automatically-placing-gerrit-s-commit-msg-hook-in-every-new-git-repository-21703.md>)

Original publisher: [Read original article](<https://nativeguru.wordpress.com/2016/04/12/automatically-placing-gerrits-commit-msg-hook-in-every-new-git-repository/>)

Author: Ramon

Published: 2016-04-12T06:42:58Z

Content type: tutorial

Language: en

Sources: [Ramon Fried](<https://devfeed.tech/sources/ramon-fried.md>)

Topics: [Git](<https://devfeed.tech/topics/git.md>), [Server](<https://devfeed.tech/topics/server.md>)

Tags: [gerrit](<https://devfeed.tech/tags/gerrit.md>), [git](<https://devfeed.tech/tags/git.md>), [hooks](<https://devfeed.tech/tags/hooks.md>), [local](<https://devfeed.tech/tags/local.md>), [server](<https://devfeed.tech/tags/server.md>), [uncategorized](<https://devfeed.tech/tags/uncategorized.md>)

## AI overview

A workaround copies Gerrit's commit-msg hook into Git's global template hooks directory so it is added to newly created repositories.

## Source excerpt

Sadly, when cloning a repository from Gerrit. the Gerrit's commit-msg hook is not populated in the local repository git hooks folder. Here's a neat trick that I just learned that always puts that there. scp -p -P 29418 <GERRIT_SERVER>:hooks/commit-msg ./ sudo mv ./commit-msg /usr/share/git-core/templates/hooks/ Hope you find it useful...