Shared git hooks

Lukas Mai

2026-03-17

Use same git hooks in all repos

# ~/.config/git/config
# (or ~/.gitconfig)

[core]
    hooksPath = ~/.local/share/git-hooks
$ mkdir -p ~/.local/share/git-hooks
$ vi ~/.local/share/git-hooks/pre-commit
...

Use same git hooks in some repos

# ~/.config/git/config
# (or ~/.gitconfig)

[includeIf "gitdir:~/project-x/"]
    path = project-x.config
# ~/.config/git/project-x.config

[core]
    hooksPath = ~/.local/share/git-hooks