当前位置: 首页 > news >正文

! [remote rejected] master -> master (pre-receive hook declined)

git push报错remote: Please remove the file from history and try again
如何快速批量修改 Git 提交记录中的用户信息

1. 问题背景

在本地做了一些修改后,进行push的时候显示如下错误:

a123@123deMacBook-Pro vue-projects % git push
Enumerating objects: 240, done.
Counting objects: 100% (240/240), done.
Delta compression using up to 8 threads
Compressing objects: 100% (178/178), done.
Writing objects: 100% (217/217), 459.31 MiB | 2.64 MiB/s, done.
Total 217 (delta 39), reused 0 (delta 0)
remote: Resolving deltas: 100% (39/39), completed with 10 local objects.
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag 8641888d
remote: Find the desired index: fa6a198045879428b61a5ca46cf9a56b4a56792c, size: 110.946MB, exceeds quota 100MB
remote: Please remove the file[s] from history and try again
To gitee.com:zhouyangwhynot/vue-projects.git! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@gitee.com:zhouyangwhynot/vue-projects.git'

2. 问题分析

根据报错描述,报错的原因是上传文件超过100M,因此我们需要找到此文件删除即可。

3. 解决问题

  1. 查看是哪个文件过大,此处对用红框里面的 fa6a198045879428b61a5ca46cf9a56b4a56792c,得到具体的文件名称
vue-projects % git rev-list --objects --all | grep fa6a198045879428b61a5ca46cf9a56b4a56792c

显示如下结果:

fa6a198045879428b61a5ca46cf9a56b4a56792c 尚硅谷Vue2教程(天禹老师主讲)/视频/005_尚硅谷Vue技术_Hello小案例.mp4.baiduyun.p.downloading
  1. 删除过大的文件:文件名称从1中得到,此处为尚硅谷Vue2教程(天禹老师主讲)/视频/005_尚硅谷Vue技术_Hello小案例.mp4.baiduyun.p.downloading
git filter-branch --tree-filter 'rm -f 尚硅谷Vue2教程(天禹老师主讲)/视频/005_尚硅谷Vue技术_Hello小案例.mp4.baiduyun.p.downloading' HEAD
WARNING: git-filter-branch has a glut of gotchas generating mangled historyrewrites.  Hit Ctrl-C before proceeding to abort, then use analternative filtering tool such as 'git filter-repo'(https://github.com/newren/git-filter-repo/) instead.  See thefilter-branch manual page for more details; to squelch this warning,set FILTER_BRANCH_SQUELCH_WARNING=1.
Proceeding with filter-branch...Rewrite 0ffcff95a18c25b93f0bf925789905f57088ba24 (62/70) (7 seconds passed, remaining 0 predicted)    
Ref 'refs/heads/master' was rewritten

最后出现Ref ‘refs/heads/master’ was rewritten则表示删除成功
3. 重新push

git push
  1. git push的时候在此报错:
git push
Enumerating objects: 239, done.
Counting objects: 100% (239/239), done.
Delta compression using up to 8 threads
Compressing objects: 100% (155/155), done.
Writing objects: 100% (216/216), 348.39 MiB | 2.30 MiB/s, done.
Total 216 (delta 36), reused 193 (delta 22)
remote: Resolving deltas: 100% (36/36), completed with 10 local objects.
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag 604953a0
remote: Find the desired index: ac0d36574ac291bcf1ee07ee08a63db9071386aa, size: 105.823MB, exceeds quota 100MB
remote: Please remove the file[s] from history and try again
To gitee.com:zhouyangwhynot/vue-projects.git! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@gitee.com:zhouyangwhynot/vue-projects.git'
  1. 使用如下命令查看是哪个文件过大
vue-projects % git rev-list --objects --all | grep ac0d36574ac291bcf1ee07ee08a63db9071386aa
# 显示结果如下:
ac0d36574ac291bcf1ee07ee08a63db9071386aa 尚硅谷Vue2教程(天禹老师主讲)/视频/003_尚硅谷Vue技术__Vue官网使用指南.mp4
  1. 使用如下命令删除过大的文件:
git filter-branch --tree-filter 'rm -f 尚硅谷Vue2教程(天禹老师主讲)/视频/003_尚硅谷Vue技术__Vue官网使用指南.mp4' HEAD
WARNING: git-filter-branch has a glut of gotchas generating mangled historyrewrites.  Hit Ctrl-C before proceeding to abort, then use analternative filtering tool such as 'git filter-repo'(https://github.com/newren/git-filter-repo/) instead.  See thefilter-branch manual page for more details; to squelch this warning,set FILTER_BRANCH_SQUELCH_WARNING=1.
Proceeding with filter-branch...Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f
  1. 执行第6步的时候报错:
Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f
  1. 出现这一句说明之前曾经执行过 git filter-branch,在 refs/original/有一个备份,这个时候只要删掉那个备份即可,删除备份命令为:
$ git update-ref -d refs/original/refs/heads/master
# 或
$ git filter-branch -f --tree-filter -f 'rm -f test' -- --all

http://www.mrgr.cn/news/64821.html

相关文章:

  • Angular解析本地json文件
  • STM32中ARR(自动重装寄存器)为什么要减1
  • ipv6的 fc00(FC00::/7) 和 fec0(FEC0::/10)
  • scp免密上传文件
  • WPS查询函数VLOOKUP,匹配寻找值自动带入值
  • M3U8直播,视频切片 AES加密,多码流自适应
  • YOLOv6-4.0部分代码阅读笔记-ema.py
  • 2024年一带一路金砖技能大赛之大数据容器云开发
  • Win10 连接到 Ubuntu 黑屏无法连接 使用Rustdesk显示 No Displays 没有显示器
  • GOF的C++软件设计模式的分类和模式名称
  • 数据结构初阶排序全解
  • 力扣周赛:第422场周赛
  • roberta融合模型创新中文新闻文本标题分类
  • 优青博导团队/免费指导/一站式服务/数据分析/实验设计/论文润色/组学技术服务 、表观组分析、互作组分析、遗传转化实验、单细胞检测与生物医学
  • ctfshow——web(总结持续更新)
  • 将分类标签转换为模型可以处理的数值格式
  • 计算机网络串联——打开网站的具体步骤
  • Linux 进程间通信 共享内存_消息队列_信号量
  • 提高交换网络可靠性之端口安全配置
  • windows rdp 将远程技术嵌入到你的软件——未来之窗行业应用跨平台架构
  • 第四次:2024年郑州马拉松赛事记
  • 什么是三大范式, 为什么要有三大范式, 什么场景下不用遵循三大范式
  • 《GBDT 算法的原理推导》 11-15更新决策树的叶子节点值 公式解析
  • Linux内核编程(十八)ADC驱动
  • 深入解析RSA算法:加密与安全性
  • Spring DispatcherServlet详解