# Why a private Git repository is not a secret store

> Putting API keys in a private repository feels safe and is not. Permanent history, flat access and weaker scanning coverage all work against it. What to use instead, and when an encrypted archive is the right answer.

Source: https://www.epifive.com/blog/private-git-repo-is-not-a-secret-store · Published 2026-11-25 · EpiFive

## Key takeaways

- Git history is permanent, so a credential committed once survives deletion and exists in every clone already taken.
- Repository access is flat: anyone who can read the repo reads every secret in it, across the whole history.
- GitHub partner auto-revocation covers public repositories, so a credential leaked in a private repo is not revoked for you.
- Secret scanning on private repositories requires a paid licence, so no alert can mean no scanning rather than no problem.
- Encrypted archives in a repository are acceptable for backup only when the passphrase is held somewhere else entirely.

"It is a private repository, so it is fine" is one of the most understandable mistakes in secrets handling. Private feels like a security boundary, and for source code it largely is. For credentials it is not, for three separate reasons that compound each other.

## Reason one: history is permanent

Git is designed never to lose anything. A credential committed once remains in the commit history after the file is changed or deleted, and it remains in every clone anyone has already taken.

This is where the usual recovery attempt fails. Deleting the file in a follow-up commit looks like a fix in the web interface, and the value is still one `git log -p` away. Rewriting history with a filter tool removes it from your copy of the repository and does nothing at all about the copy on a laptop that was cloned last week, or the copy in a CI cache, or the copy in a backup of either.

The only reliable response to a committed credential is rotation. History rewriting is optional cleanup you may choose to do afterwards, for tidiness rather than for safety.

## Reason two: access is flat

Repository permissions are coarse. Anyone who can read the repository can read every file in it, across the whole of its history. There is no mechanism to grant somebody the deployment script without also granting them the credentials sitting next to it.

That becomes a live problem the moment the repository is shared with a contractor, connected to a CI runner, or added to an integration that requests read access. Each of those is an ordinary, reasonable action, and each one quietly hands over the entire credential set rather than the part that was needed.

Compare that with a proper secret store, where automation can use a value it cannot print, and a person can be granted one secret without the others. The difference is not encryption. It is that the store understands the difference between using a secret and reading it.

## Reason three: scanning coverage is weaker than people assume

This is the reason most often stated incorrectly, including in advice that is otherwise sound, so it is worth being precise.

GitHub operates a secret scanning partner program with a large number of token providers. When a credential matching a partner pattern is found, the provider can be notified and can revoke the credential. **This applies to public repositories and public npm packages.** For a private repository, GitHub's documentation describes the alert going to repository administrators and the committer, not to the partner. Nothing is revoked on your behalf.

There is a second limitation on top of that one. Secret scanning for organisation-owned private and internal repositories is a paid capability, documented as part of GitHub Secret Protection on Team or Enterprise Cloud plans. Push protection for private repositories sits behind the same licence, while free public repositories receive scanning and push protection by default.

Put those two together and the practical position is uncomfortable:

| | Public repository | Private repository |
| --- | --- | --- |
| Scanned by default | Yes | No, needs a paid licence |
| Push protection by default | Yes | No, needs a paid licence |
| Partner notified, credential may be revoked | Yes | No |

A private repository is therefore not the safer place to put a credential. It is the place where a committed credential is least likely to be noticed, by you or by anyone else, and where nothing external will step in to limit the damage.

**Do not read a quiet repository as a clean one.** No alert can mean no problem, or it can mean no scanning. Those are very different situations and they look identical from the outside.

## What to use instead

Match the store to how the secret is used, not to what is convenient at the moment you need somewhere to put it.

| Secret is used by | Store | Can you read it back? |
| --- | --- | --- |
| CI jobs and automation | Platform encrypted secret store | No, by design |
| Application at run time | Platform environment variables or a secret manager | Depends on the platform |
| A person, occasionally | Password manager | Yes |
| Disaster recovery | Encrypted archive, passphrase held separately | Yes, with the passphrase |

The important column is the third one. CI secret stores are write-only on purpose: you set a value, jobs consume it, nobody reads it back. That is a feature rather than a limitation, and it is also the reason a CI secret store is not a backup. If the only copy of a credential lives in a CI secret store and you need to see it, the answer is to generate a new one.

Most setups therefore need two stores rather than one: the CI store for automation to consume, and a password manager or encrypted archive for the copy a human can recover.

## The encrypted archive pattern

For backups specifically, a repository is acceptable as transport provided the contents are encrypted before they go in.

The shape is simple. Collect the sensitive files, encrypt the archive with a strong symmetric cipher and a high key derivation iteration count, commit the ciphertext, and keep the passphrase somewhere else entirely, such as a password manager. Record a checksum so you can verify the archive before you trust it, and split very large archives into parts if your host enforces a file size limit.

What makes this safe is not that the repository is private. It is that the repository holds ciphertext, which is useless to anyone who obtains it without the passphrase. The repository being private is a second layer, not the first one, and the design should survive that layer failing.

The failure mode to avoid is both obvious and common: committing the passphrase, or a convenience script containing the passphrase, or a README explaining where the passphrase is kept, into the same repository as the archive. Each of those collapses the two factors back into one.

## A short checklist

- Credentials never go into a repository in readable form, private or not.
- Automation reads secrets from the platform's encrypted store, by name.
- People read secrets from a password manager.
- Backups are encrypted archives with the passphrase held elsewhere.
- Any credential that reached a repository in readable form is rotated, regardless of whether an alert ever appeared.
- Secret scanning status is checked rather than assumed, particularly on private repositories where it may not be enabled at all.

## What we checked

- Consulted GitHub's secret scanning partner program documentation and the secret scanning overview on 2026-11-25, and recorded that partner scanning covers public repositories and public npm packages, with partner notification and possible revocation for those matches.
- Recorded from the same documentation that for private repositories the alert is routed to repository administrators and the committer rather than to the partner, so no external revocation occurs.
- Recorded that secret scanning for organisation-owned private and internal repositories is documented as part of GitHub Secret Protection on Team or Enterprise Cloud plans, and that push protection on private repositories sits behind the same licence while free public repositories receive both by default.
- Verified on a real private repository on 2026-11-25 that the secret scanning alerts API returned a "Secret scanning is disabled on this repository" response, confirming that a private repository can have no scanning coverage at all.
- Reviewed GitHub changelog entries from March and June 2026 describing expanded push protection defaults and additional partners, and found nothing extending partner auto-revocation to private repositories.
- Not verified: behaviour on GitHub Enterprise Server, and the equivalent arrangements on GitLab and Bitbucket, which have their own scanning products and licensing. Check your own platform rather than generalising from GitHub.
- Not verified: whether any specific provider revokes tokens found in private repositories through its own independent monitoring. Some may; that is a provider decision and not something the platform promises.

Last tested: 2026-11-25

## References

- GitHub Docs: secret scanning partner program, for which repository types are scanned and who is notified.
- GitHub Docs: about secret scanning, for licensing of private and internal repository coverage.
- GitHub Changelog, March and June 2026 entries, for push protection defaults and partner additions.

## Frequently asked questions

### Is a private repository safe for storing API keys?

No. Private controls who can clone the repository, not what happens to the values inside it. Anyone with read access gets every secret, the history keeps them after deletion, and any clone on any machine carries a full copy.

### If I push a token to a private repo, will GitHub revoke it?

No. GitHub's partner program scans public repositories and public npm packages, and for those matches the partner handles revocation. For private repositories the alert goes to repository administrators and the committer, not to the provider, so nothing is revoked for you.

### Does my private repository get secret scanning at all?

Only with a paid licence. GitHub documents secret scanning for organisation-owned private and internal repositories as part of GitHub Secret Protection on Team or Enterprise Cloud. Without it, a committed credential can sit undetected indefinitely.

### Does deleting the file in a later commit fix the problem?

No. The value stays in commit history and in every existing clone. You have to rotate the credential. Rewriting history is optional cleanup that does nothing about copies other people already hold.

### Can I store secrets in a repository if they are encrypted?

Yes, that is a reasonable backup pattern, provided the passphrase or decryption key is held somewhere else entirely. The repository then holds ciphertext, which is useless on its own.

