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'

相关推荐
用什么都重名4 分钟前
Git分支合并与远程服务器同步实战:保留关键配置文件
运维·服务器·git
得要找到一束光35 分钟前
git详细命令
git·github
2601_961875242 小时前
花生十三公考课程|网课|视频
数据库·windows·git·svn·eclipse·github
EleganceJiaBao6 小时前
【Git】Git reset 完整指南:真正理解 HEAD、暂存区与工作区
git·github·reset
我最爱吃鱼香茄子8 小时前
【保姆级】Git配置用户名和邮箱(全局/局部)解决提交记录不识别、贡献图不亮问题
git·gitee·github·小白教程·git配置·程序员开发工具
weixin_571667418 小时前
git fork 并建立自己的dev分支 保持与源仓库的联系
git
master3368 小时前
git仓库通过脚本完成多个远程仓库同步
大数据·git·elasticsearch
用什么都重名8 小时前
Git 合并两个无共同历史的分支:从报错到解决全记录
git·gitlab
2601_961875249 小时前
花生十三资料网盘|百度云|下载
数据库·windows·git·svn·eclipse·github
小香猪66889 小时前
Git 日常操作完全指南:提交、冲突、分支、账户配置一站式教程
git