---
title: "Operator lesson 5: Purging what must go"
description: "Purge a committed secret's contents for good while every commit keeps its ID, see every read say so, see the forge refuse to bring them back, and find the purge in a compliance report."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.forge.workreef.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Operator lesson 5: Purging what must go

**Time:** 20 minutes. **Track:** [operator](https://docs.forge.workreef.dev/learn/#operator). **Before this:** [operator lesson 1](https://docs.forge.workreef.dev/learn/operators/vault-and-keys/).

By the end of this lesson you will be able to:

- purge a file's contents from history, every commit keeping its ID;
- say what a purge refuses, and why;
- find a purge in a compliance report, and when it is an exception.

## A secret on main

A purge is for contents that must go for good: a committed secret, or personal data someone has the right to have erased. Start a forge, land a password, then land its removal:

```console server
$ af-server --dev
...
```

```console check
$ source ~/af-dev/dev/env
$ af workspace add ~/demo
Workspace at /home/you/demo
Paths: **
main has no landing yet
$ cd ~/demo
$ af new -m "Add the settings"
Working on change muqxoylnyqxrzkxkryxsqwrrplrlozxs at commit 28eb8f8150ebfd13ecb84dec6eb9205dedc8ce019526357f116ed13d63508f36
$ printf 'user=deploy\npassword=hunter2\n' > settings.ini
$ af submit
Submitted commit d39e2d34949ad7bcd6634d98ccc4120b82ab1e68d435f628dc2d1c3e9135b809, 1 edit in its last snapshot
```

```console eventually
$ af main
d39e2d34949ad7bcd6634d98ccc4120b82ab1e68d435f628dc2d1c3e9135b809
```

```console check
$ af new -m "Take the password out"
Working on change uzuvmsuqmnyktuontlunlmqxxwnsortp at commit 5a487d5c82c0d2b7db73a01726b7a0c1b6c6142b0c0513baf2660eacef865d33
$ printf 'user=deploy\n' > settings.ini
$ af submit
Submitted commit 51e622961b710175bca21a21119eabd08b093d57e0732dd97eac9f339ae63b40, 1 edit in its last snapshot
```

```console eventually
$ af main
51e622961b710175bca21a21119eabd08b093d57e0732dd97eac9f339ae63b40
```

## Purge it

The removal had to land first: contents main still holds are refused, as `hg censor` refuses a head. Purge the version with the password, in the commit below main. An administrator asks, and it takes effect at once, on their word, unless the forge requires a second administrator:

```console check
$ af purge settings.ini -r 'main-' --reason "a password was committed"
purges 33b349f4fedd9a9be90d90b9de78a6c14f4da1f6d90d5e5bda2062d596fea4ae
done: it took effect at once, on your word as an administrator
$ af file show settings.ini -r 'main-'
Error: settings.ini at d39e2d34949ad7bcd6634d98ccc4120b82ab1e68d435f628dc2d1c3e9135b809 is withheld: the contents 33b349f4fedd9a9be90d90b9de78a6c14f4da1f6d90d5e5bda2062d596fea4ae were purged, as the organization's record 4 approved: they are neither read nor stored again
[1]
```

The commit is still there, with its ID: a commit's ID depends on its files' IDs, never on their bytes, so every receipt and workspace that names it stays valid. Only the bytes are gone, and every read says so, naming the record that approved it.

## It does not come back

Reverting the landing that took the password out would bring it back. The forge refuses:

```console check
$ af revert -r 'main'
Error: PermissionDenied: refused: a revert of 51e622961b710175bca21a21119eabd08b093d57e0732dd97eac9f339ae63b40 would bring back contents purged since
[1]
```

An upload of the contents, or a snapshot that names them, is refused the same way: once purged, they are neither read nor stored again.

## In the report

A purge is a privileged change, and a compliance report lists each one as evidence: approved, and what the repository then made of it, from the repository's own record of it, made or refused. Approved by its asker alone, on an administrator's own word, it is an exception the report names as well:

```console check
$ af report iso27001 --from 2026-01-01T00:00:00Z --to 2100-01-01T00:00:00Z --out ~/report
wrote /home/you/report/iso27001-report.json and /home/you/report/iso27001-report.html; the report's receipt is entry 5 of the log
$ grep -o '[A-Z][a-z]*: the purge of [^"]*' ~/report/iso27001-report.json | sort -u
Evidence: the purge of settings.ini in main at 1 commit approved; made in the repository, 1 stored content removed (entry 7 of the repository's log) (2026-11-26T04:32:13.004Z, entry 4 of the organization's receipt log).
Exception: the purge of settings.ini in main at 1 commit approved; made in the repository, 1 stored content removed (entry 7 of the repository's log): approved by no one else, an administrator's own word (2026-11-26T04:32:13.004Z, entry 4 of the organization's receipt log).
```

The report names the purge by its path and repository, never its contents. So does its reason, which is kept for good: never put in a reason what the purge takes away.

## Exercises

1. Show the purged commit's metadata. What is still there?

   ```console check
   $ af show -r 'main-'
   Commit ID: d39e2d34949ad7bcd6634d98ccc4120b82ab1e68d435f628dc2d1c3e9135b809
   Author   : Developer <dev@localhost> (2026-11-25T15:24:38Z)
   Parents  : 0000000000000000000000000000000000000000000000000000000000000000

       Add the settings

   A settings.ini
   ```

2. Try to purge what main holds now.

   ```console check
   $ af purge settings.ini -r 'main' --reason "the user name too"
   Error: the contents are current: main holds them at settings.ini; land their removal first
   [1]
   ```

## Check your understanding

<details>
<summary>Why does a purge not rewrite history, as filtering a git repository does?</summary>

Rewriting would give every later commit a new ID, breaking every receipt, workspace and record that names one. A purge removes only the bytes; every commit keeps its ID, and every read names what was purged and the record that approved it.

</details>

<details>
<summary>Why must the removal land before the purge?</summary>

So that main never holds contents it cannot read. While main, or an open or submitted change, still holds them, the purge is refused: land their removal first.

</details>

<details>
<summary>What can a purge not reach?</summary>

Copies outside the forge: a workspace that checked the file out keeps its copy, as a clone keeps what `hg censor` erased later. Treat a purged secret as exposed, and rotate it. A file's name and a commit's description cannot be purged either.

</details>

## Next

That is the operator track's lessons for one machine. [What is kept and what goes](https://docs.forge.workreef.dev/concepts/lifecycle/) explains purges and collection in depth.

Source: https://docs.forge.workreef.dev/learn/operators/purging/index.mdx
