Home > OS >  Git lfs can't push angular project because files exceed file size of 100.00 mb
Git lfs can't push angular project because files exceed file size of 100.00 mb

Time:11-09

I'm trying to push my entire local repository into my github repository. I have added the repo, committed the repo and added the remote repository. I have installed git lfs, checked that git lfs is installed, added git lfs tracks(see below) and added the .gitattribute. When I try to push the repo through gitbash I still get the following error:

$ git push -u origin main
Enter passphrase for key '/c/Users/{username}/.ssh/id_ed25519':
Enumerating objects: 2195, done.
Counting objects: 100% (2195/2195), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2177/2177), done.
Writing objects: 100% (2195/2195), 308.15 MiB | 109.00 KiB/s, done.
Total 2195 (delta 260), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (260/260), done.
remote: warning: File angular-project/src/.angular/cache/14.1.2/angular-webpack/35e551783499373efd8f37ab5f2cf30081d207ca/4.pack is 54.39 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: warning: File angular-project/src/.angular/cache/14.1.2/angular-webpack/4b90ebc77ad46c8187dd39ece1f934df6779c2c7/1.pack is 68.87 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: warning: File angular-project/src/.angular/cache/14.1.2/angular-webpack/4b90ebc77ad46c8187dd39ece1f934df6779c2c7/14.pack is 78.10 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: warning: File angular-project/src/.angular/cache/14.1.2/angular-webpack/fa9214961fba2fcc3fd6f2576fd07fb1f688a64e/0.pack is 80.18 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: warning: File angular-project/src/.angular/cache/14.1.2/angular-webpack/2aa86d3e302d06a540894c9353d3e857f45ae6fe/1.pack is 54.41 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: warning: File angular-project/src/.angular/cache/14.1.2/angular-webpack/2fb2dbbb412a1a3ffc842af340939ed15ae8319f/6.pack is 80.31 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: error: Trace: a66c432f3fd91922f522d4a48c5c75fa4666bc9a454592c6e5c2a4b90a43ab57
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File angular-project/src/.angular/cache/14.1.2/angular-webpack/108df82e36d14c5cbf52cede86e23c14ff10c600/5.pack is 137.00 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File angular-project/src/.angular/cache/14.1.2/angular-webpack/3759c7aedb3be007ae7758b97a55606e66f9aa5b/5.pack is 151.27 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File angular-project/src/.angular/cache/14.1.2/angular-webpack/f9027151ddc69bc6b2be7ad182cc6b78434b351f/0.pack is 148.02 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File angular-project/src/.angular/cache/14.1.2/angular-webpack/13982179bb9f378b179431598132bd35fa0f4a47/13.pack is 150.41 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File angular-project/src/.angular/cache/14.1.2/angular-webpack/4540ee20ba8425d06b5e2c926f071f1d67056684/0.pack is 152.56 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 github.com:{github username}/{projectname}.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'github.com:{github username}/{projectname}.git'

I have tried the following git lfs track commands:

$ git lfs track "angular-project/src/.angular/cache/14.1.2/angular-webpack/*"

$ git lfs track "angular-project/src/.angular/cache/14.1.2/angular-webpack/**"

$ git lfs track "angular-project/*"

$ git lfs track "angular-project/**"

$ git lfs track "*.pack"

But nothing has resolved the problem. Am I using the wrong syntax? If anyone can help me resolve my problem please let me know.

CodePudding user response:

There are certain files and folders that are generated by the application during development and deployment. These should not be committed to your repo.

You need to add a .gitignore file at the root to exclude that content.

https://git-scm.com/docs/gitignore

Updating with a link explaining how to remove these now ignored files from your local commit.

https://betterprogramming.pub/how-to-remove-committed-files-from-git-version-control-b6533b8f9044

Here's a sample file from the Angular project. You can see that .angular/cache is listed under Miscellaneous.

https://github.com/angular/angular/blob/main/aio/.gitignore

# See https://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out
/src/generated

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
/.firebase/
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
firebase-debug.log
testem.log
/typings

# e2e
protractor-results*.txt

# System files
.DS_Store
Thumbs.db
  • Related