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'

相关推荐
Merrick3 小时前
git撤销第一次commit
git
艾莉丝努力练剑5 小时前
【Git:基本操作】深度解析Git:从初始Git到熟悉基本操作
大数据·linux·c++·人工智能·git·gitee·指令
大白要努力!6 小时前
将Git项目的所有远程分支打包成压缩包文件
git
牧羊人_myr6 小时前
Git指令集
git
边疆.8 小时前
【Linux】版本控制器Git和调试器—gdb/cgdb的使用
linux·服务器·git·gdb调试·cgdb
安冬的码畜日常17 小时前
【JUnit实战3_22】 第十三章:用 JUnit 5 做持续集成(下):Jenkins + JUnit 5 + Git 持续集成本地实战演练完整复盘
git·测试工具·ci/cd·jenkins·集成测试·持续集成·junit5
wxxka19 小时前
git使用
开发语言·git
舒一笑20 小时前
用数据照亮成长之路:PandaCoder Git 统计工具窗口
git·后端·intellij idea
测试修炼手册1 天前
[测试工具] 如何把离线的项目加入成为git项目的新分支
git