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'

相关推荐
疯狂的沙粒1 小时前
如何通过git命令查看项目连接的仓库地址?
大数据·git·elasticsearch
qq_254617772 小时前
Gerrit+repo管理git仓库,如果本地有新分支不能执行repo sync来同步远程所有修改,会报错
git
π大星星️3 小时前
Git分布式版本控制工具
分布式·git
kingbal3 小时前
IDEA:配置 Git 需要完成 Git 路径设置、账号认证以及仓库关联三个主要步骤
git·idea
司徒小夜15 小时前
处理git没做修改,但是文件显示变更的情况
git
m0_7493175216 小时前
vscode里如何用git
ide·git·vscode
Hello.Reader17 小时前
Git 安装全攻略Linux、macOS、Windows 与源码编译
linux·git·macos
王景程17 小时前
SELinux是什么以及如何编写SELinux策略
git·github
Chuncheng's blog18 小时前
如何基于Mihomo Party http端口配置git与bash命令行代理
git·http·bash
Tom Boom18 小时前
Git常用命令完全指南:从入门到精通
大数据·git·elasticsearch·docker·自动化测试框架