Git 大文件问题解决办法

最合适的办法是改用 Git LFS。你的电脑已经安装了 git-lfs,而且远端还没有成功接收任何提交,处理非常简单。Gitee 官方也建议大文件使用 LFS,但会受账号 LFS 额度限制。Gitee 官方说明https://gitee.com/help/articles/4232_

在项目根目录执行:

复制代码
cd D:\zlx\simulateTool\simulateTool

git lfs install

git lfs track "public/models/*.glb"

git add .gitattributes

git add --renormalize -- "public/models"

git status --short

确认暂存区主要是 .gitattributes 和原来已经纳入 Git 的模型文件,然后改写尚未推送成功的首次提交:

复制代码
git commit --amend --no-edit

确认大模型已经转成 LFS:

复制代码
git lfs ls-files

列表中应该包含:

复制代码
public/models/xxx.glb
public/models/xxxxxx.glb
public/models/xxxxxx.glb

然后重新推送:

复制代码
git push -u origin master

这里不需要 --force,因为刚才远端整体拒绝了首次推送,远端 master 尚未成功建立。

当前未提交的爆炸效果、卡片和场景配置修改不会被上述 commit --amend 自动带进去,因为命令只暂存 .gitattributes 和已跟踪的模型文件。后续正常执行:

复制代码
git add .
git commit -m "完善三维仿真场景和爆炸效果"
git push

新增加的 .glb 也会自动通过 LFS 上传。不要直接使用 git rm 删除导弹模型,也不要执行 git reset --hard

相关推荐
高调的涵涵6 小时前
删了1.2GB,.git仍是1.2GB
git
程序员沉梦听雨8 小时前
【Git】git-submodule子模块管理
git
全栈陈序员1 天前
Git】从入门到精通(八)—— git log:查看提交历史
大数据·git·elasticsearch
7177771 天前
Git自建用什么工具比较好:Gitea、Forgejo、GitLab CE与Gitee的选型对比
git·gitlab·gitea
lsc_blog2 天前
年底还在招的岗位,先确认缺口和到岗要求
git·缓存·ci/cd·职场和发展·github
全栈陈序员2 天前
【Git】从入门到精通(十一)—— git reset 三种模式详解
git·elasticsearch
全栈陈序员3 天前
【Git】从入门到精通(十)—— 撤销与恢复:git checkout与git restore
运维·网络·数据库·git
全栈陈序员3 天前
【Git】从入门到精通(五)—— git add:将文件加入暂存区
大数据·git·elasticsearch
全栈陈序员3 天前
【Git】从入门到精通(七)—— git status:查看仓库状态
大数据·git·elasticsearch
莫晓燚3 天前
Ansible 13 个常用模块---企业实战
git·github