Sub topic 12
Forks, pull request refs, caches, and old clones
This chapter assumes you have already rotated the credential, rewritten history with git filter-repo, verified the result, and force-pushed. Those steps clean the branches and tags you pushed. They do not clean every copy of the old history.
Why old history survives
A force-push moves your branch and tag pointers to new commits. The old commits are no longer reachable from those refs, but they can still exist in other places. Anyone who has the old commit hash can often still fetch it.
Forks
A fork is a separate repository with its own copy of the history. Your force-push does not change it. If the secret was in the repository before the fork was made, every fork still contains it.
You cannot rewrite someone else's fork. Ask the fork owners to delete the fork or to rewrite it the same way. On some hosts, deleting the parent repository does not delete its forks.
Pull request refs
Hosts store pull request (or merge request) commits under special refs. GitHub uses refs/pull/<number>/head. GitLab uses refs/merge-requests/<number>/head. A normal git push --force --all does not touch these refs, so a pull request that included the secret keeps it.
You can list the refs your host exposes:
git ls-remote origin 'refs/pull/*'You cannot usually delete these refs yourself. On GitHub, you ask GitHub Support to remove the cached views and the pull request refs that hold the sensitive data. Other hosts have similar processes, so check your host's documentation.
Caches and unreachable objects
Hosts keep unreachable objects for a while, and some serve commits by hash even when no branch points to them. A direct link such as /commit/<old-hash> may still work after your force-push. The host's support team can run garbage collection on the repository to remove those objects.
Other systems may also hold copies:
| Place | What to do |
|---|---|
| CI caches and build artifacts | Delete the caches and artifacts built from old commits |
| Package registries and release assets | Remove any published package or archive that contains the secret |
| Mirrors and backups | Re-sync the mirrors, or delete and recreate them |
| Code search and third-party indexes | Request removal, if the repository was public |
Old local clones
Every collaborator's clone still has the old objects. Even in your own working clone, the reflog keeps old commits reachable for a time. If you keep a clone that existed before the rewrite, expire the reflog and prune it:
git reflog expire --expire=now --all
git gc --prune=now --aggressiveFor collaborators, deleting the old clone and cloning again is safer than cleaning it. A teammate who merges old branches into the rewritten history can push the secret back in.
A practical checklist
- Confirm the credential is revoked and replaced.
- List
refs/pull/*orrefs/merge-requests/*and note any that include the secret. - Contact the host's support to purge cached views, pull request refs, and unreachable objects.
- Ask fork owners to delete or rewrite their forks.
- Clear CI caches, artifacts, and published packages that were built from old commits.
- Tell collaborators to re-clone, as covered in the next chapter.
Exercise
After you force-push a cleaned history, a pull request opened last month still shows the commit containing the secret, and the old commit URL still loads. Why did the force-push not remove it, and what should you do?
Show answer
The force-push only moved your branch and tag refs. The host keeps the pull request commits under its own refs (such as refs/pull/<number>/head) and keeps unreachable objects until garbage collection runs. You cannot delete those refs yourself. Contact the host's support to purge the pull request refs, cached views, and old objects. Rotate the credential if you have not already, because anyone who saw the commit still has the secret.