您的位置:首页 > 健康 > 美食 > 设计分为几种类型_网络关键字优化_网络推广网上营销_科技网站建设公司

设计分为几种类型_网络关键字优化_网络推广网上营销_科技网站建设公司

2024/12/23 14:50:28 来源:https://blog.csdn.net/zy_whynot/article/details/143467945  浏览:    关键词:设计分为几种类型_网络关键字优化_网络推广网上营销_科技网站建设公司
设计分为几种类型_网络关键字优化_网络推广网上营销_科技网站建设公司

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

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com