git push出错Push cannot contain secrets

报错原因:

因为你的代码里面包含了github token明文信息,github担心你的token会泄漏,所以就不允许你推送这些内容。

解决办法:

需要先把代码里面的github token信息删除掉,并且删掉之前的历史提交,只要包含token的提交,都要删除掉。

或者按照官方给的解决办法:Working with push protection from the command line - GitHub Docs

然后再次提交,就可以了

详细的报错:

git push

Enumerating objects: 40, done.

Counting objects: 100% (40/40), done.

Delta compression using up to 8 threads

Compressing objects: 100% (26/26), done.

Writing objects: 100% (28/28), 8.67 KiB | 4.33 MiB/s, done.

Total 28 (delta 16), reused 0 (delta 0), pack-reused 0

remote: Resolving deltas: 100% (16/16), completed with 9 local objects.

remote: error: GH013: Repository rule violations found for refs/heads/main.

remote:

remote: - GITHUB PUSH PROTECTION

remote: ---------------------------------------------------------------------------------------------------------------------------

remote: Resolve the following violations before pushing again

remote:

remote: - Push cannot contain secrets

remote:

remote:

remote: (?) Learn how to resolve a blocked push

remote: https://docs.github.com/code-security/secret-scanning/working-with-secret-scanning-and-push-protection/working-with-push-protection-from-the-command-line#resolving-a-blocked-push

remote:

remote:

remote: ------ GitHub Personal Access Token ------------------------------------------------------------------

remote: locations:

remote: - commit: 28e55de0d31e3a863b7e252ef802230b56b13092

remote: path: src/apis/common.ts:8

remote: - commit: 28e55de0d31e3a863b7e252ef802230b56b13092

remote: path: src/utils/http.ts:56

remote:

remote: (?) To push, remove secret from commit(s) or follow this URL to allow the secret.

remote: https://github.com/Sjj1024/PakePlus/security/secret-scanning/unblock-secret/2mDtj7K5gyE4MfiZ7e8IyJqZfaK

remote:

remote:

remote:

To github.com:Sjj1024/PakePlus.git

! [remote rejected] main -> main (push declined due to repository rule violations)

error: failed to push some refs to 'github.com:Sjj1024/PakePlus.git'

相关推荐
Э时间行者于我2 小时前
git同时删除多个分支
git
我的golang之路果然有问题9 小时前
给git配置SSH(github,gitee)
经验分享·笔记·git·学习·gitee·ssh·github
漫步企鹅10 小时前
[Git] Git Stash 命令详解
git·git push·git pull·git commit·git pull rebase
船长@Quant12 小时前
协作开发攻略:Git全面使用指南 — 第二部分 高级技巧与最佳实践
git·版本控制·源代码管理·协作开发
用户126538387051214 小时前
github 和 gitee 配置问题及相关问题解决
git·github
极小狐15 小时前
极狐GitLab Git LFS 速率限制如何设置?
运维·git·ssh·gitlab·github
极小狐15 小时前
如何解决极狐GitLab 合并冲突?
人工智能·git·机器学习·gitlab
一袋米扛几楼9815 小时前
【GIT】github中的仓库如何删除?
git·github
hjm470219215 小时前
GIT 使用小记
git
程序猿chen1 天前
JVM考古现场(二十五):逆熵者·时间晶体的永恒之战(进阶篇)
java·jvm·git·后端·程序人生·java-ee·改行学it