remote: 此仓库的限制大小为: 2048 MB, 您的使用已经超出限额

Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 392.33 MiB | 7.45 MiB/s, done.
Total 6 (delta 4), reused 0 (delta 0), pack-reused 0
remote: 此仓库的限制大小为: 2048 MB, 您的使用已经超出限额
remote: error: hook declined to update refs/heads/master
To https://code.aliyun.com/x-demo/学校学.git
! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'https://code.aliyun.com/x-demo/学校学.git'
 

当遇到 Git 提交时仓库大小超过配额限制(Repo size: 1157.395MB, exceeds quota 1024MB)的问题,可以尝试以下方法解决: ### 使用 `git filter-branch` 清除历史记录中的大文件 若大文件曾被提交到仓库,即便已删除,其历史记录仍可能存在于仓库中,占用空间。可使用 `git filter-branch` 命令清除历史记录中的大文件。示例命令如下: ```bash git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch 提交的文件的名字" -- --all ``` 此命令会重写仓库的提交历史,移除指定文件的所有记录。使用该命令时需谨慎,因为它会改变仓库的历史记录,可能影响与其他开发者的协作。完成操作后,需强制推送至远程仓库: ```bash git push origin --force --all ``` ### 使用 `git filter-repo` 删除旧提交 可以使用 `git filter-repo` 删除超过一定时间的旧提交,仅保留最近的记录。示例如下: ```bash # 进入新的仓库目录 cd new-repo.git # 运行清理旧数据命令 git filter-repo --commit-callback ' import datetime timestamp_str = commit.committer_date.decode().split()[0] commit_date = datetime.datetime.fromtimestamp(int(timestamp_str)) current_date = datetime.datetime.now() if (current_date - commit_date).days > 365: skip_commit = True ' --force # 强制推送到远程仓库 git remote set-url origin <remote-repo-url> git push origin --force --all git push origin --force --tags # 优化仓库 git gc --prune=now --aggressive ``` 此方法会移除超过一年的提交记录,减少仓库大小。 ### 检查并清理暂存区和缓存 有时候,大文件可能仍存在于暂存区或缓存中。可使用以下命令清理暂存区和缓存: ```bash git rm -r --cached . git add . git commit -m "Clear cache and re-add files" git push origin <branch_name> ``` ### 检查子模块 若仓库包含子模块,子模块的大小也会计入仓库大小。可检查子模块是否存在大文件,若有,可按上述方法处理子模块中的大文件。 ### 联系管理员提高配额 若上述方法无法满足需求,可联系仓库管理员,请求提高仓库的配额限制
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值