From 13034b3ef034084bf59d50d1496709162a632fe6 Mon Sep 17 00:00:00 2001 From: Bronco Oostermeyer Date: Tue, 30 Dec 2025 12:27:54 +0100 Subject: [PATCH] added .githooks dir, prevent local commits in main --- .githooks/README.md | 14 ++++++++++++++ .githooks/pre-commit | 6 ++++++ 2 files changed, 20 insertions(+) create mode 100644 .githooks/README.md create mode 100644 .githooks/pre-commit diff --git a/.githooks/README.md b/.githooks/README.md new file mode 100644 index 0000000..0f6a7cc --- /dev/null +++ b/.githooks/README.md @@ -0,0 +1,14 @@ +# `.githooks` directory + +Because the `.git\hooks` is invisible and therefor harder to add to the repo the following construct is made. All hooks are part of the repo and are located in the `.githooks` directory, which can be committed. + +To notify git to look in the `.githooks` directory, execute the following: + +``` +git config core.hooksPath .githooks +``` + +If you want this behavior for all repos: +``` +git config --global core.hooksPath .githooks +``` diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100644 index 0000000..4f0fcc6 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,6 @@ +#!/bin/bash +branch=$(git rev-parse --abbrev-ref HEAD) +if [ "$branch" = "main" ]; then + echo "No commits on man branch allowed" + exit 1 +fi