1The lock Entra does not cover
Session 02 named two separate gates in this site's pipeline: Entra ID in front of the published pages, and the GitHub repository's own privacy setting in front of the source and its history. Every session since has been about the files Entra shows you once you sign in. This session is about the other gate, the one guarding the repository itself, because the two protect genuinely different things.
Entra decides who can view the rendered pages this site publishes. The repository's privacy setting decides who can see the source behind those pages, every commit ever made, every message written, and every file that was ever part of the project, including ones removed later. A repository can be set to public by mistake while Entra is configured perfectly, and the result is still a real exposure.
2Why a public repository is a real exposure
A public GitHub repository is readable by anyone with the link, no account or sign-in required, and it stays readable forever at every point in its history, not just its current state. Session 01 showed that a commit is a complete snapshot and that history never shrinks on its own. Those two facts together are exactly what makes a public repository risky: it is not only today's files on display, it is every version of every file this project has ever had, including anything that was later edited to remove something sensitive.
This training site's repository holds internal structure, draft material, and the exact mechanics of how Hermetic's internal site gets published, including the pipeline session 02 walked through. None of that is written for a public audience, which is reason enough on its own for the repository to stay private, before a single credential is ever at stake.
3What never belongs in a commit
A private repository is still not a safe place for certain things, because private can become public by a changed setting, a departing employee, or a mistake, and because anyone with legitimate access today is still more people than a secret should ever be shared with. Treat the following as things that never get committed, to any branch, private or not:
Credentials
Passwords, API keys, access tokens, and connection strings that include a username and password. Any one of these found in a commit should be treated as compromised the moment it is found, which section 5 covers.
Configuration files built to hold secrets
Files named .env, or anything described as holding keys or credentials for a specific
service, are built for exactly this content and should never be tracked by git at all.
Client or personal data
Anything identifying a real client or a real person beyond what this training site's own labeled model data already shows. If it would not belong in a published page, it does not belong in a commit either.
Anything you would not want read aloud
A useful, quick test: if a commit message or a file's contents would be uncomfortable read aloud in a staff meeting, it is worth a second look before it is staged.
4.gitignore: telling git what to never track
A file named .gitignore, sitting in the top of a repository, lists patterns for files
git should never track, stage, or warn you about, no matter how many times they change. This repository
already has one, and its entire current content is one line:
.849C9593-D756-4E56-8D6E-42412F2A707B |
That single line blocks one specific, auto-generated system file some Windows folders pick up, which
has nothing to do with secrets; it is there because the file is noise, not because it is sensitive. The
mechanism, though, is exactly what secrets protection relies on. A project that will ever hold a
.env file, an API key, or any file built to carry a credential should add a line for it
to .gitignore before that file is ever created, so that git status never
even offers to stage it by accident.
It stops git from tracking a file from this point on. It does nothing for a file that was already committed before the pattern was added; that file is already in the history, and removing it from the working tree later does not remove it from the commits behind it. The pattern has to exist before the sensitive file is first created and committed.
5What to actually do if a secret leaks anyway
It happens, including to experienced teams, and the response matters more than the mistake. The one rule that overrides every instinct to quietly clean it up: deleting the file in a new commit does not remove it from history. The old commit, with the secret in full, still exists and is still reachable by anyone who can see the repository, exactly as session 01 described a commit as permanent once made.
- Treat the credential as compromised the instant it is found in a commit, whether or not it was ever pushed, and whether or not the repository is private.
- Rotate or revoke it immediately, through whatever service issued it. A new key is cheap. A key that may have been seen by the wrong person is not something a later commit can take back.
- Only after it is rotated, remove the file from the current working tree with a normal commit, so it stops appearing in new work.
- If the secret must also be scrubbed from the history itself, that is a separate, harder operation that rewrites commits, and it is worth a second person's help the first time; it is out of scope for this session, but rotating the credential is not optional while you decide whether to do it.
6The one habit that catches most of this
Session 03 introduced git status and git diff as the check that would have
caught an unrelated file riding along in a commit. The same habit is the main defense here: read what
you are about to stage, every time, before you stage it. A credential sitting in a file you are about
to commit shows up in that diff exactly like any other line would.
7Try it: see .gitignore do its job
In your practice folder.
- Create a file named
.envcontaining one fake line, such asAPI_KEY=not-a-real-key. - Run
git status. Right now, git lists it as untracked, exactly like any new file, because nothing has told this practice repo to ignore it yet. - Create a
.gitignorefile in the same folder containing one line:.env. - Run
git statusagain. The.envfile no longer appears at all. Git is not merely declining to stage it; it has stopped mentioning it. - Stage and commit the new
.gitignorefile itself, with a message describing what it protects.
8Check for understanding
-
Answer
The two settings are independent. Entra ID decides who can view the rendered site. The repository's own privacy setting decides who can see the source and every commit behind it. Getting one right says nothing about the other, which is why both need to be checked.
-
Answer
Deleting a file in a new commit only changes what the current working tree shows. The earlier commit where the credential was added is untouched and still exists in full, reachable by anyone with access to the repository, which is why the real response is to rotate the credential rather than assume a later commit fixed anything.
-
Answer
.gitignore changes nothing about history that already exists. It tells git never to track a matching file from this point forward. A file already committed before the pattern existed stays exactly where it is in the history, which is why the rule has to be in place before a sensitive file is ever created, not after.
-
Answer
Rotating or revoking the credential is the one action that actually removes the risk, regardless of whether the repository was private or whether anyone is known to have seen it. Everything else, deleting the file, restricting access further, is worth doing too, but none of it substitutes for treating the credential itself as compromised.
-
Answer
The real entry blocks a specific, auto-generated system file, noise rather than anything sensitive. It shows the mechanism correctly, that a listed pattern is never tracked, but a project that might ever hold a credential needs its own lines added for that, such as .env, before such a file is first created.
9Before session 08
- Locate where your own copy of
HN - Training, or any repository you work in, actually lives on disk. Session 08 asks whether that location is safe.
10Glossary
- Private repository
- A repository readable only by people explicitly granted access, as opposed to a public one readable by anyone with the link.
- .gitignore
- A file listing patterns git will never track, stage, or report on, from the point the pattern is added onward.
- Secret / credential
- A password, API key, token, or connection string that grants access to a system and must never be committed.
- Credential rotation
- Replacing a credential with a new one and invalidating the old, the correct first response to any leaked secret.
- History rewrite
- An operation that edits past commits directly to remove content from them, a separate and harder step from simply deleting a file in a new commit.
11Sources
- GitHub, Keeping your credentials secure and Removing sensitive data from a repository, GitHub Docs.
- Git, gitignore documentation, git-scm.com.
- HN - Training's own .gitignore, read directly from the repository, 2026-10-03.