Pre-receive hooks
2 min
using pre receive hooks pre receive hooks are custom scripts that git runs server side whenever new commits are pushed to a repository they inspect incoming changes before acceptance, enforcing standards and rules without requiring users to install pre commit hooks they're available on self hosted platforms such as github enterprise server gitlab self managed bitbucket data center note implementation details vary by provider, be sure to consult your provider's documentation for specific setup instructions to run as a pre receive hook, the scanner must be invoked via bash script using the git scanner the bare option is required since the full repository isn't available in the context of a pre receive hook the trufflehog binary must be executable and in the $path variable for the git instance the example below should work in most environments, though file naming conventions differ some platforms accept arbitrary script names, e g trufflehog hook sh , while gitlab requires the script name to reflect the hook type, e g pre receive note trufflehog in the script below refers to the open source scanner pre receive script for trufflehog \#!/bin/bash /trufflehog no update git bare file // only verified fail