Interview Prep/Git & GitHub/GitHub, Actions and Pull Request Issues

Push rejected: `remote: - GITHUB PUSH PROTECTION` and `Push cannot contain secrets` pointing at a commit from three commits ago.

IntermediateTroubleshootingGitHub, Actions and Pull Request Issues
Answer

Likely causes → Secret scanning push protection found a credential pattern (AWS key, GitHub token, Slack webhook) in one of the commits you are pushing — not necessarily the latest one. Removing it in a new commit does not help; it is still in history.

Diagnose → The output lists the secret type, commit SHA and path. Confirm with git show <sha> -- <path>.

Fix → Remove it from the commit itself, then push:

git rebase -i <sha>^          # mark the commit as "edit"
# remove the secret from the file, use an env var instead
git add config/app.yml && git commit --amend --no-edit
git rebase --continue
git push

If the secret was real, rotate it. Only use the "allow secret" link for verified false positives or test credentials.

Prevent → Run gitleaks or trufflehog in pre-commit, and load secrets from a vault or environment.

All Git & GitHub questions Roadmap: Git & GitHub

More on GitHub, Actions and Pull Request Issues