# 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: [Gerrit](<https://devfeed.tech/topics/gerrit.md>), [Git](<https://devfeed.tech/topics/git.md>)

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

## AI overview

The excerpt proposes copying Gerrit's `commit-msg` hook with `scp` on port 29418, then moving it into `/usr/share/git-core/templates/hooks/` so new Git repositories receive the hook. The server value is missing from the shown command.

## 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...