git - Github 推送因文件过大而被拒绝
问题描述
我正在处理一个电子项目,由于文件大小超过 100.0 MB,我的推送被 github 拒绝。我尝试使用 git lfs 但我仍然面临错误。
使用这些命令:
$ 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 官方示例应用程序所做的那样,通常我们忽略node_modules/
Git 中的 dir。(见https://github.com/electron/electron-quick-start)
所以添加node_modules
到.gitignore
. 不用担心。package.json
保留所有依赖项,以便您可以通过命令重建node_modules
目录。npm install
推荐阅读
- api - 如果 graphql 是一种查询语言,为什么它用在前端而不是后端?
- apify - PuppeteerCrawler 和 Task 的 Settigs 差异
- oracle - PLS-00103:结束而不是编译指示最终实例化顺序覆盖静态成员构造函数映射
- java - JSP 代码超出了 65535 字节的限制 - Tomcat 9 修复
- android - 只要应用程序打开,如何使用socket.io保持活跃的android webview
- java - 哪些声明是有效的?
- php - Foreach 循环和 cURL 请求的问题
- json - 在句子(句子数组)中的任何位置找到确切的两个单词 elastcsearch 6.8
- c# - 如何在 Unity 上的 Google OnAdclose 上访问从一个 GameObject 到另一个 GameObject 的方法?
- laravel-5 - 数据表 - 用图标替换值适用于一个单元格而不是两个单元格