Github推送因文件大而被拒绝 [英] Github push declined due to large file size

查看:37
本文介绍了Github推送因文件大而被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个电子项目,由于文件大小大于100.0 MB,github拒绝了我的推送.我尝试使用git lfs,但仍然遇到错误.

I am working with an electron project and my push is declined by github due to a large file size greater than 100.0 MB. I tried using git lfs but I am still facing an error.

使用以下命令:

$ git init
$ cd node_modules/electron/dist
$ git lfs track electron.d.ts     # this is the large file
$ cd -
$ git add .gitattributes
$ git add .
$ git commit -m "First Push"
$ git remote add origin "Name of my git repo"
$ git push origin master

错误如下:

git push origin master
Username for 'https://github.com': rCandy-Tewari
Password for 'https://Candy-Tewari@github.com': 
Username for 'https://github.com': Candy-Tewari
Password for 'https://Candy-Tewari@github.com': 
Uploading LFS objects: 100% (1/1), 529 KB | 94 KB/s, done.                            
Enumerating objects: 4693, done.
Counting objects: 100% (4693/4693), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4451/4451), done.
Writing objects: 100% (4693/4693), 69.20 MiB | 322.00 KiB/s, done.
Total 4693 (delta 815), reused 0 (delta 0)
remote: Resolving deltas: 100% (815/815), done.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 186f2969412378dbb7e6aac9c37d1534
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File node_modules/electron/dist/electron is 110.07 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/Candy-Tewari/MediumOS--Electron-App.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/Candy-Tewari/MediumOS--Electron-App.git'

推荐答案

通常, node_modules 的目录大小非常大.正如Electron官方示例应用程序所做的那样,通常我们会忽略Git中的 node_modules/目录.(请参见 https://github.com/electron/electron-quick-start )

Typically, node_modules dir size is very large. As the Electron official sample application does, usually we ignore node_modules/ dir in Git. (see https://github.com/electron/electron-quick-start )

因此将 node_modules 添加到 .gitignore 中.不用担心 package.json 保留所有依赖性,以便您可以通过 npm install 命令重建 node_modules 目录.

So add node_modules to .gitignore. Don't worry. package.json keeps all dependencies so that you can rebuild node_modules dir by npm install command.

这篇关于Github推送因文件大而被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆