Push protection is a check that stops you uploading code that seems to contain a password or key.
This guide is for students, new developers and anyone who has just seen "push blocked" and wants to know what to do. You do not need to be an expert to fix it: most blocks are solved on your own computer in a few calm steps.
In short
- A blocked push means the code site found something that looks like a password or key in your new work.
- The block happens before your work is stored on the site, so it is a safety net, not a fault.
- Deleting the line in a new save is not enough. The key must come out of every save the message lists.
- If the key was copied anywhere else, change it at the service that issued it.
What you will learn
- Explain what push protection and secret scanning do.
- Read a blocked push message and find the key it points to.
- Choose between fixing the code and using a bypass reason.
- Check whether the key needs changing as well.
- Sending your work (push)
- uploading your saved changes from your computer to the shared project.
- Key finder (secret scanner)
- a tool that looks through code for passwords, keys and tokens.
- Upload check (push protection)
- a secret scanner that runs at the moment you push and can refuse the upload.
What is push protection?
Think of a post office counter. The clerk spots a bank card showing through your envelope and hands the envelope back before it is posted. Push protection does the same for code.
Developers save their work in a tool called Git. Each deliberate save is a commit. When they are ready, they push, which means they upload those commits to a shared project on a code site such as GitHub or GitLab.
Some code sites run a secret scanner at that moment. It looks for known kinds of password, key or token. These are the secrets that apps and other non-human identities (NHIs), such as service accounts and AI agents, use to prove who they are. If the scanner finds one, the site refuses the push and tells you where it is.[1]
Where the comparison stops working: a clerk looks at one envelope. A push can carry many saves, and the key may sit in an older one, not just the latest.
Why does it matter?
A key that reaches a shared project can be copied by everyone who can read it. Push protection tries to catch the key before it is stored there, so you can fix the code first.[1]
If you are learning to code
What could happen: you add a test key "just for now", your push is blocked and you are not sure why.
Check this: read the message slowly. It names the kind of key, the file and the line.
If you are new to a developer job
What could happen: you click a bypass to get past the block, and an alert goes to the project's owners.
Check this: ask your team when a bypass is allowed before you need one.
If you lead a small team
What could happen: people learn to bypass every block, and real keys slip through.
Check this: agree who may bypass, and review each bypass that happens.
What does it look like?
On the command line, a blocked push shows a short report. Here is a simplified, made-up one. Real messages differ by code site.
Example only. All values are made up.
remote: Push blocked: secret found (1) remote: Type: Example Cloud access key (2) remote: locations: remote: commit: 0000aaaa path: app/config.txt:4 (3) remote: commit: 0000bbbb path: app/config.txt:4 (3) remote: To allow this secret, visit: remote: https://code.example.invalid/allow/0000 (4) ! [remote rejected] main (push declined) (5)
- The headline. The site found something that looks like a secret.
- The kind of key. In a real message, this line would name the service that issued it.
- Each save that holds the key, with the file and line number. Here the key is in two saves.
- A link to the bypass page. Use it only when the value is not a working key and your team allows bypasses.
- The push was refused. Nothing from it was stored on the site.
Why this is risky: the quick reaction is to delete line 4 in a new save and push again. That push is blocked too, because the two older saves still hold the key.[2]
The safer way: take the key out of every save the message lists, then push again. Keep the key in a secrets store, a locked place that hands it to the app when it runs.
How does it work?
Here is what happens from your push to a fixed upload.
- You push. Your saves travel from your computer to the code site.
- The site checks. A scanner compares the new changes with patterns for known kinds of key. GitLab, for example, checks for patterns it is confident about.[4]
- The site decides. If nothing matches, the push is accepted. If a key matches, the push is refused, with a report of where the key sits.[1]
- You fix it locally. You remove the key from the latest save, or from each older save the report lists. Git can rewrite saves that never reached the site, so this stays on your computer.[2]
- You push again. If the block comes back, the key is still in a save you missed.

Sometimes the scanner flags a value that is not a real key. Code sites offer a way past the block, called a bypass. On GitHub you pick a reason: "It's used in tests", "It's a false positive" or "I'll fix it later". You then have three hours to push again.[2] A false positive is a value that only looks like a key.
Each reason has a result. On a project with secret scanning turned on, the bypass is recorded and owners are emailed. "I'll fix it later" leaves an open alert for someone to deal with.[1] Some teams turn off the bypass link. Then you send a request with a short reason, and a reviewer approves or refuses it.[2]

Scanners have limits. They look for patterns they support, so unusual or custom passwords can be missed.[1] GitLab says it skips some content, such as very large files.[4] A push that gets through is not proof that it holds no secrets.
A worked example
Wren Sorensen is a student on a work placement at a fictional design studio. Her lead is Mira Lindahl. Wren has added a weather feature to the studio's website and tries to push it.
The push is refused. The message names a cloud access key in a settings file, line 4, and lists two saves. Wren's first thought is to delete the line and try again. She remembers the post office counter. The clerk handed the envelope back, so nothing has been posted yet.
She reads the message properly. The key is in two saves, not one. A new save that deletes the line would leave both older saves holding the key. So she messages Mira before doing anything else.
Mira asks one question first. "Did that key go anywhere else?" Wren checks. She pasted it into a team chat yesterday to ask for help. That means the key has been seen outside her computer.
So the order is clear. Mira changes the key at the cloud service, and the studio's app is updated to use the new one. Once the change has taken effect, the old key should no longer give access to anyone who copied it.
Then Wren removes the key from both saves on her own computer, following the steps in the studio's guide. The new key goes into the hosting service's secure settings. Her code now holds only the name of the setting. She pushes again, and it is accepted.
Mira thanks Wren for asking before using the bypass link. They add one line to the team notes: "A real key is never a false positive."
Myths and mistakes
| What people think | What is true |
|---|---|
| Deleting the line and pushing again will fix it. | The key must be removed from every save that holds it, not just the newest.[2] |
| The push was blocked, so the key is safe. | It was not stored on the site. If you also pasted or shared it elsewhere, change it. |
| The bypass link is a quick way to get on with work. | A bypass is a statement about the value. It can be recorded and can alert the project's owners.[1] |
| "False positive" is fine if I plan to fix it soon. | A real key is not a false positive. Pick the reason that is true. |
| If my push is accepted, my code has no secrets. | Scanners check known patterns and can miss custom passwords.[1] |
What can I do this week?
- Find out whether push protection is on for the projects you work in.
- Ask your team when a bypass is allowed and who approves requests.
- Move any keys in your settings files into a secrets store or secure settings.
- Agree the order after a block: stop, read the message, ask "was it shared?", then fix.
Checklist
- I read the whole message before changing anything.
- I know which kind of key was found and which saves hold it.
- The key is removed from every listed save, not just the newest one.
- If the key was shared anywhere else, it has been changed at the service that issued it.
- The key now lives in a secrets store or secure settings, not in the code.
- Any bypass reason I chose is true.
- I told my lead or team about any real key.
Common questions
Why does my push still fail after I deleted the key?
Because older saves still hold it. Deleting the line in a new save leaves the key in the earlier saves listed in the message. Remove it from each of those saves on your computer, then push again. See What to do when git push is blocked by secret scanning push protection.
Do I need to change the key if the push was blocked?
Not always. If the key only ever sat in saves on your own computer, removing it may be enough. If you pasted it into chat, a ticket or another project, or pushed it somewhere else, change it at the service that issued it. If unsure, change it.
Is it all right to use the bypass link?
Only when the reason is true and your team allows it. A bypass says the value is a test value, not a key, or a key you will deal with later. It can be recorded and can alert the project's owners, so ask your lead first if you are unsure.
Why is there no bypass link in my message?
Your project probably needs approval for bypasses. Instead of a link to skip the block, you send a request with a short reason. A reviewer approves or refuses it, and you hear back by email. If it is refused, remove the key from your saves.
Where next?
Ready for the detail? Read the practitioner guide: What to do when git push is blocked by secret scanning push protection. It goes further into the exact Git steps for older saves, each bypass reason and how bypass requests are reviewed.
Also useful:
- Push Protection Guide
- Developer Secret Scanning Triage
- Secrets in Code for Beginners
- Personal Access Tokens for Beginners
- Non-Human Identities for Beginners
Related NHI Mgmt Group resources: How to enable GitHub secret scanning push protection · How to Remove Secrets From Git History · Git Secret Scanning Guide
Key terms
- Push protection
- A code site feature that blocks uploads holding known kinds of secret.
- Secrets scanning
- Looking through code and files for passwords, keys and tokens.
- Secret
- A password, key, token or certificate that software uses to prove who it is.
- Commit
- A snapshot of changes that a developer chooses to save in Git, kept in the project's history.
- False positive
- A warning about something that turns out not to be a problem, such as text that only looks like a key.
- Secrets rotation
- Replacing a secret with a new one so the old copy no longer gives access.
Sources and further reading
- About push protection. GitHub Docs, GitHub. https://docs.github.com/en/code-security/concepts/secret-security/push-protection, accessed 28 Nov 2026.
- Working with push protection from the command line. GitHub Docs, GitHub. https://docs.github.com/en/code-security/secret-scanning/working-with-secret-scanning-and-push-protection/working-with-push-protection-from-the-command-line, accessed 28 Nov 2026.
- Push protection for users. GitHub Docs, GitHub. https://docs.github.com/en/code-security/secret-scanning/working-with-secret-scanning-and-push-protection/push-protection-for-users, accessed 28 Nov 2026.
- Secret push protection. GitLab Docs, GitLab. https://docs.gitlab.com/user/application_security/secret_detection/secret_push_protection/, accessed 28 Nov 2026.