Version control is a system that records every change to a set of files so you can go back later.
This guide is for anyone who hears words like Git, repository or commit and wants a plain explanation. You do not need to code. If your business has an app or website, its code is likely to live in one of these systems.
In short
- Source code is kept in a repository, a store that holds the files and their full history.
- Git is a common tool for this, and every full copy carries the whole history.
- Because history is kept, a password or key saved once can stay readable in older versions and copies.
- If a secret is saved by mistake, change or cancel it first, then clean up.
What you will learn
- Explain what a repository, commit, branch, fork and pull request are.
- Describe why deleting a file does not remove it from history.
- Spot the tokens and keys that tools use to reach your code.
- Check the first steps to take if a secret is saved by mistake.
- Code store (repository)
- a folder of project files plus the full record of every saved change.
- Saved change (commit)
- a snapshot of the files that someone chose to save, with a note saying what changed.
- Software password (secret)
- a key, token or password a program uses to prove it may connect.
What is version control?
Think of a shared document that keeps every past version. Anyone can scroll back and see what it said last week, and who changed it.
Version control does this for code. It records changes to files over time so you can bring back an older version, compare changes and see who changed what [1]. A widely known tool for this is called Git.
The project lives in a repository (often shortened to "repo"), which holds the files and their history. Each time a developer chooses to save their work, they make a commit. A commit stores a snapshot of the files, the author's name and a short message [2].
Where the comparison stops working: a shared document usually lives in one place. With Git, each person who makes a full copy gets the whole history on their own computer, not just the latest version [1].
Why does it matter?
Code stores often hold more than code. Settings files, keys and tokens can end up there too, and the history keeps them.
If you own a small business with an app
What could happen: a supplier saves your payment key in a public code store, and a stranger copies it.
Check this: ask whether your code store is private, and who can see it.
If you are learning to code
What could happen: you paste a key into a file to test something, commit it and push it to a public site.
Check this: keep keys out of your project folder from day one.
If you look after IT for a team
What could happen: an old access token for the code store still works long after the tool that used it was retired.
Check this: list the tokens and keys that tools use to reach your code.
What does it look like?
Here is a made-up history for a small website project. Newest changes are at the top.
Example only. All values are made up.
repository: EXAMPLE-cafe-website branch: main (1)
commit 0000c3 "Remove database password from settings" (2)
commit 0000b2 "Add booking form settings" (3)
settings.txt: DB_PASSWORD=FAKE-0000
commit 0000a1 "First version of menu page" (4)
- The project store and the main line of work, called a branch.
- The newest commit removes the password from the current files.
- In a real file, this line would contain the database password, still readable in this older commit.
- The first saved version of the project.
Why this is risky: anyone with a copy of the history can open commit 0000b2 and read the password.
The safer way: change the password first, so the old one no longer works. Keep secrets in a locked store, not in the project files.
How does it work?
- Copy. A developer makes a full copy of the repository, called a clone. It includes the history [1].
- Branch. They start a branch, a separate line of work, so they can make changes without disturbing the main line [2].
- Commit. They save their changes as one or more commits.
- Push and propose. They upload, or push, the commits to the shared store. Then they open a pull request, which is a proposal to merge their changes into the main line [3].
- Review and merge. Someone checks the changes, and they are joined into the main line.

A fork is a separate repository that starts as a copy of another one. On one popular hosting site, forks of public repositories are public too [4].
A file called .gitignore tells Git which files to leave out of future saves. It does not affect files Git is already tracking [5]. So it can help avoid new mistakes, but it does not clean up old ones.
Tools reach code stores too. A build service or an AI coding helper uses a token or key to read and write code. Each of those tools is a non-human identity (software with its own access). One hosting site's guidance recommends giving such credentials the minimum permissions possible [6].
A worked example
Odile Yilmaz has just started a coding course. She builds a small weather app that calls an online weather service. The service gives her a key to use.
To get it working quickly, she types the key straight into her code. She commits the change and pushes it to a public repository to show her tutor.
The next day she remembers a warning from her course. She deletes the line, makes a new commit and pushes again. The key is gone from the current files.
Her tutor explains that the key is still in the older commit. Anyone who cloned or forked the project may also have a copy. One hosting site's guidance says that if a commit with sensitive data exists in any forks, it stays reachable there [7].
So Odile follows the order that guidance gives: revoke or rotate the secret first [7]. She logs in to the weather service, cancels the old key and creates a new one. Once that change has taken effect, the old copy should no longer give access.
She stores the new key in a settings file outside her project and adds that file name to .gitignore. She also turns on secret scanning, a feature that checks a repository's history for saved credentials [8].
Odile now treats every key as a password for software. It does not belong in code, even for a quick test.
Myths and mistakes
| What people think | What is true |
|---|---|
| Deleting the line removes the secret. | Older commits, clones and forks can still hold it. Change the secret first. |
| Git saves every keystroke. | Git saves only when someone makes a commit. Each commit is a deliberate save. |
| Adding a file to .gitignore hides it. | It only stops future saves. Files already tracked stay in the history. |
| A private repository is a safe place for keys. | Many people and tools can read private stores. Keep keys in a locked secrets store instead. |
| Only people use the code store. | Build services, bots and AI helpers use tokens to reach it. Each one needs an owner. |
What can I do this week?
- Ask where your organisation's code is stored and whether each store is public or private.
- List the tools and tokens that can read or change your code.
- Turn on secret scanning where your hosting service offers it.
- Agree a simple rule: if a secret is saved by mistake, change it first and tell the owner.
Checklist
- We know where all our code stores are.
- Each store is marked public or private on purpose.
- Changes to the main line go through a review.
- Secrets are kept in a locked store, not in code.
- Secret scanning is turned on where available.
- Every token a tool uses to reach code has an owner and limited access.
- We have a short plan for a secret saved by mistake.
Common questions
Is Git the same as GitHub?
No. Git is the version control tool that records changes. GitHub is one of several online services that host Git repositories and add features such as pull requests and secret scanning. GitLab is another such service.
What is the difference between a clone and a fork?
A clone is a full copy of a repository, usually on someone's own computer. A fork is a separate repository on a hosting service that starts as a copy of another one. Both can carry the full history, including any old secrets.
Can I just rewrite the history to remove a secret?
You can, but change the secret first. Rewriting history has side effects for everyone working on the project. It also cannot reach copies other people already made, so the old secret may still exist elsewhere.
Why does a build tool need a token for my code?
It needs to read the code to build it, and sometimes to write results back. The token proves the tool may do that. Because the tool acts on its own, it is a non-human identity, and its token needs the same care as a password.
Where next?
Ready for the detail? Read the practitioner guide: Git Repository Security Guide. It goes further into access settings, branch protection rules and history clean-up.
Also useful:
- Secrets in Code for Beginners
- Secret Scanning for Beginners
- Leaked Secret Response for Beginners
- Commit Signing for Beginners
Related NHI Mgmt Group resources: Non-Human Identities for Beginners, Exposed .git and .env Files for Beginners and Git Secret Scanning Guide.
Key terms
- Git
- A version control tool that tracks changes to files, with the full history kept in each copy.
- Repository
- A store for project files plus their history of changes.
- Commit
- A saved snapshot of changes, with the author and time, kept in the history.
- Branch
- A separate line of work that can be merged back into the main code later.
- Fork
- A separate copy of a codebase that starts from the original project.
- Pull request
- A proposal to merge changes into another branch, opened for review first.
- Secret
- The credential, such as a key, token or password, that proves a non-human identity may act.
Sources and further reading
- Scott Chacon and Ben Straub, "Getting Started: About Version Control", Pro Git, 2nd edition. https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control (accessed 1 Dec 2026).
- Scott Chacon and Ben Straub, "Git Branching: Branches in a Nutshell", Pro Git, 2nd edition. https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell (accessed 1 Dec 2026).
- GitHub Docs, "Pull requests". https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests (accessed 1 Dec 2026).
- GitHub Docs, "Forks". https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/about-forks (accessed 1 Dec 2026).
- Git project, "gitignore Documentation". https://git-scm.com/docs/gitignore (accessed 1 Dec 2026).
- GitHub Docs, "Secrets", GitHub Actions. https://docs.github.com/en/actions/concepts/security/secrets (accessed 1 Dec 2026).
- GitHub Docs, "Removing sensitive data from a repository". https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository (accessed 1 Dec 2026).
- GitHub Docs, "Secret scanning". https://docs.github.com/en/code-security/secret-scanning/introduction/about-secret-scanning (accessed 1 Dec 2026).