---
title: Block secrets from leaking
slug: docs/block-secrets-from-leaking
icon: ✋
docTags: 
createdAt: 2024-04-18T13:55:23.151Z
---

What's better than cleaning up leaked secrets? Blocking them from leaking in the first place, of course!

TruffleHog offers two ways of preventing secrets from leaking in Git:


```mermaid
graph TD
A{Is the git server self-hosted?}
A -->|Yes| B[Prereceive hooks block secrets from being accepted at the git server]
A -->|No| C{Apply precommit hooks with TruffleHog}
C --> D[Prevent secrets from being pushed to the git server]
B --> E[End]
D --> E[End]
```

::::LinkArray
:::LinkArrayItem{headerType="COLOR"}
[Pre-commit hooks](docId\:ZZSnWMyFYAV-EyLOHxpXj)
:::

:::LinkArrayItem{headerType="COLOR"}
[Pre-receive hooks](docId:84n9z_iTulB2670bKUTSs)
:::
::::

