无法将代码推送到 GitHub,节点模块太大

问题描述 投票:0回答:1

我有一个带有根目录和客户端目录的反应项目。早些时候,我像往常一样只在根目录中工作,但我决定为我一直在编写的前端代码创建一个新的客户端目录,同时将后端代码保留在根目录中。进行此分离后,我无法将我的代码推送到 GitHub。我收到一条错误消息,指出客户端文件夹中的 node_modules 包含太大的文件。我尝试创建一个新的存储库并推送到那里,但结果仍然相同,所以问题似乎来自我的代码库。我已将node_modules添加到根目录中的gitignore文件夹中,这样它就不会被推送到存储库,但仍然无济于事。我什至尝试过使用 git LFS 来存储大文件,但仍然遇到相同的错误。我已经完成了大部分项目,从那时起我就一直将代码推送到我的存储库。这个问题就是凭空出现的。这是我在终端中收到的消息

说到这里,停顿了好久:

git push --set-upstream origin master
Enumerating objects: 44178, done.
Counting objects: 100% (44178/44178), done.
Delta compression using up to 4 threads
Compressing objects: 100% (31530/31530), done.
Writing objects: 100% (44175/44175), 386.79 MiB | 15.49 MiB/s, done.
Total 44175 (delta 11605), reused 43933 (delta 11488), pack-reused 0

最终,这是完整的消息:

$ git push --set-upstream origin master
Enumerating objects: 44178, done.
Counting objects: 100% (44178/44178), done.
Delta compression using up to 4 threads
Compressing objects: 100% (31530/31530), done.
Writing objects: 100% (44175/44175), 386.79 MiB | 15.49 MiB/s, done.
Total 44175 (delta 11605), reused 43933 (delta 11488), pack-reused 0
remote: Resolving deltas: 100% (11605/11605), completed with 1 local object.
remote: error: Trace: 404752adfd4ea24fa4470b58cfe8deab2314f93248e63256a319fb89bcdc4128
remote: error: See https://gh.io/lfs for more information.
remote: error: File client/node_modules/.cache/default-development/1.pack is 133.46 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File client/node_modules/.cache/default-development/10.pack is 409.51 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File client/node_modules/.cache/default-development/13.pack is 415.16 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File client/node_modules/.cache/default-development/24.pack is 132.23 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File client/node_modules/.cache/default-development/27.pack is 406.89 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To https://github.com/ojieprincewill/baroque.git
 ! [remote rejected]   master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/ojieprincewill/baroque.git'
reactjs github node-modules
1个回答
0
投票
  1. 在应用程序的根文件夹中创建 .gitignore 文件。
  2. 插入此行:/node_modules
  3. 提交您的更改并将其推送到 git。

*如果您在创建 .gitignore 文件之前已经进行了提交,则应该关闭终端并再次提交。

© www.soinside.com 2019 - 2024. All rights reserved.