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://gitee.com/youyacao/www.youyacao.com.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to ‘https://gitee.com/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://gitee.com/youyacao/www.youyacao.com.git backup-repo
  1. 重新克隆仓库: 克隆一个新的仓库,以便在干净的历史记录上工作。
git clone https://gitee.com/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://gitee.com/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” 错误解析什么是历史分支优雅草卓伊凡
447 4
深度解决 Git “fatal: refusing to merge unrelated histories” 错误解析什么是历史分支优雅草卓伊凡
|
6月前
|
存储 NoSQL 开发工具
Git Clone 原理详解:为什么它比本地文件复制更快? -优雅草卓伊凡
Git Clone 原理详解:为什么它比本地文件复制更快? -优雅草卓伊凡
193 26
Git Clone 原理详解:为什么它比本地文件复制更快? -优雅草卓伊凡
|
1月前
|
安全 开发工具 git
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
229 5
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
|
1月前
|
Shell Linux 网络安全
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
369 3
宝塔服务器面板部署安装git通过第三方应用安装收费怎么办—bash: git: command not found解决方案-优雅草卓伊凡
|
4月前
|
算法 安全 网络安全
git clone操作报错diffie-hellman-group1-sha1的解决方案
在处理这一问题时,需要确保了解相关操作的安全影响。`diffie-hellman-group1-sha1`算法被认为是不够安全的,这是因为随着计算能力的提高,`SHA-1`算法可以在合理的时间内被破解,而且其对应的 `1024位`Diffie-Hellman组也可能不够强大。因此,在确保Git操作的同时,也要考虑提升安全性的长期解决办法。强烈推荐与管理员或相关技术支持团队合作,升级和加强服务器端的安全配置。
133 12
|
6月前
|
存储 Linux 开发工具
Git:现代软件开发的基石——原理、实践与行业智慧·优雅草卓伊凡
Git:现代软件开发的基石——原理、实践与行业智慧·优雅草卓伊凡
191 21
Git:现代软件开发的基石——原理、实践与行业智慧·优雅草卓伊凡
|
5月前
|
存储 人工智能 缓存
Git Commit规范:为什么有些公司要求变更行数限制?·优雅草卓伊凡
Git Commit规范:为什么有些公司要求变更行数限制?·优雅草卓伊凡
245 3
Git Commit规范:为什么有些公司要求变更行数限制?·优雅草卓伊凡
|
7月前
|
Shell 开发工具 git
解决git bash报错:在仓库中检测到可疑的所有权
总的来说,解决“在仓库中检测到可疑的所有权”的报错,关键在于理解和调整文件或目录的所有权。只要我们正确地设置了文件或目录的所有权,那么我们就可以避免这种问题,让Git Bash正常工作。
283 22
|
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>优雅草卓伊凡
161 21
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
|
5月前
|
网络协议 开发工具 git
解决 git 报错 “fatal: unable to access ‘https://github.com/.../.git‘: Recv failure Connection was rese
在使用 Git/Git小乌龟 进行代码管理的过程中,经常会遇到各种各样的问题,其中之一就是在执行 git clone 或 git pull 等操作时出现 “fatal: unable to access ‘https://github.com/…/.git’: Recv failure Connection was reset” 的报错。这个问题通常是由网络连接问题或代理设置不正确导致的。在我的个人使用经验中,我亲自尝试了四种方法,它们都能够有效地解决这个报错。个人比较推荐方法二。
2781 0