Unable to Push to GitHub Due to Secret Scanning #140034
Replies: 1 comment
-
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
-
Code Security
Bug
Body
I am trying to push a large set of changes to a new GitHub repository, but my pushes are being rejected due to GitHub's Push Protection detecting secrets in previous commits. The push fails with the following error: `remote: error: GH013: Repository rule violations found for refs/heads/main.
Troubleshooting Methods Tried (All Failed)
Initial Push Attempt
Tried pushing the repository normally after removing the sensitive file.
Result: GitHub Push Protection blocked the push due to the presence of API keys in the Git history.
Increased Buffer Size
Increased the http.postBuffer size using:
git config --global http.postBuffer 524288000
Result: The push still failed due to detected secrets.
Forced Push to New Repository
Created a new GitHub repository with the URL: https://github.com/anna-rosew/return-to-the-source.git
Attempted to push the changes using:
git push new-origin main --force
Result: The push failed due to both the size of the repository and the Push Protection error regarding the same API key in the commit history.
Tried Git Interactive Rebase
Used git rebase -i to manually edit old commits containing the sensitive information:
Ran:
git rebase -i HEAD~n
Marked the problematic commits for editing and removed sensitive data using git rm and git commit --amend.
Result: This method did not solve the problem, as the secrets were from older commits not easily accessed via this approach.
Used git filter-repo to Remove Sensitive Data
Installed and used git filter-repo to remove the sensitive file from the history:
git filter-repo --path secrets.env --invert-paths
Result: This seemed to rewrite the history locally, but pushing still failed due to GitHub detecting the same API key.At this point, I have attempted numerous methods to clean the commit history and push the project, but I am blocked by the detection of secrets. I’ve tried filtering the repo, increasing buffer size, and pushing to a new repository, all of which have failed.
Beta Was this translation helpful? Give feedback.
All reactions