29

I recently upgraded all of my dependencies in package.json to the latest. I went from Angular 12.2.0 to 13.0.1 and github is now rejecting my push with the following file size error. Is there some setting I need to define in angular.json build profile that will help minimize these cache file sizes?

remote: warning: File .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/3.pack is 54.01 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: warning: File .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/2.pack is 56.42 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: error: Trace: 0b9557fffbe30aac33f6d9858ef97559341c5c1614ace35524fcba85ac99ca76
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/3.pack is 122.06 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/5.pack is 123.92 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File .angular/cache/angular-webpack/f48e9bc724ec0d5ae9a9d2fed858970d0a503f10/0.pack is 154.05 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File .angular/cache/angular-webpack/9327900b3187f0b6351b4801d208e7b58f1af17e/0.pack is 165.50 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File .angular/cache/angular-webpack/663bcd30d50863949acf1c25f02b95cab85c248a/0.pack is 151.56 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File .angular/cache/angular-webpack/663bcd30d50863949acf1c25f02b95cab85c248a/0.pack is 151.55 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.

Edit:

  1. I created this repo with Angular cli and have been maintaining and updating through many versions of Angular and had no issue until this latest update.

  2. The .gitignore file is in the root of the application and matches the suggested example: enter image description here

  3. When adding /.angular/cache to the gitignore file, I run git rm -rf --cached . && git add . && git commit -m 'fix(gitignore): add angular cache' && git push --set-upstream origin chore/bump-deps but still get the file size error.

S. Taylor
  • 401
  • 2
  • 6
  • 10
  • 9
    Do you have `/.angular/cache` in your *.gitignore* file? You don't want to include these files in source control. – R. Richards Nov 23 '21 at 21:34
  • Thanks, @R.Richards . I should have thought of that. Now I'm having trouble with understanding the gitifnore file. I've added all of the following permutations and ran `git rm -r --cached` . and still no luck getting it to work: ./.angular/* .angular/* ./.angular/ .angular/ ./.angular .angular – S. Taylor Nov 23 '21 at 22:54
  • Best approach here is to find a popular Angular 13 demo/repo on GitHub and copy/compare the `.gitignore` - could be you're just missing a `/` or `*` somewhere – Drenai Nov 24 '21 at 00:19
  • Do you have other solutions for this? currently experiencing it I don't want to lose my git history – Sherwin Ablaña Dapito Dec 16 '21 at 12:48
  • @S.Taylor you're missing a dot in your command - try `git rm -r --cached .` – matzar Jan 06 '22 at 14:08
  • The steps to update your `.gitignore` are: 1. Add a path to your `.gitignore` (in this case `.angular/cache` 2. Run `git rm -r --cached .` 3. Commit changes And that's it. Your `.gitignore` should be now working properly. – matzar Jan 06 '22 at 14:10

2 Answers2

36

Make sure your .gitignore is in the parent folder of .angular.
In that .gitignore file, a simple .angular/cache/ should be enough to ignore that subfolder content.

Check it with:

git check-ignore -v -- .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/2.pack

You can see an example in ganatan/angular-starter/.gitignore (from an Angular 13 Example Starter project), where /.angular/cache/ is used, to anchor the rule to the top folder of the repository.

The OP S. Taylor confirms in the comments:

I'm pretty sure that was my issue.
I abandoned the dev branch and updated my dependencies without using the compound commands like git add . && git commit -m 'fix(gitignore): add angular cache'.
Making sure to note what was staged.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for the reply @VonC. The check-ignore command seems to report back that the file is being ignored by the rule on line 35, `/.angular/cache` , but I still get the size warning: `$ git check-ignore -v -- .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/2.pack .gitignore:35:/.angular/cache .angular/cache/angular-webpack/72163742903fc8ba00e684045de261c2e3a2fb86/2.pack` – S. Taylor Nov 24 '21 at 14:23
  • 1
    @S.Taylor It is possible that folder was tracked before in a past commit, and it would be that commit which triggers the error message during the `git push`. Install git-sizer then, once the large commit identified with git-sizer, remove the commit with git filter-repo, as described in https://stackoverflow.com/a/66452371/6309. git-sizer on Windows (should you be on Windows): https://stackoverflow.com/a/66452371/6309 – VonC Nov 24 '21 at 14:37
  • 1
    Thanks @VonC, I'm pretty sure that was my issue. I didn't want to install git-sizer if I could avoid it, so I abandoned the dev branch and updated my dependencies without using the compound commands like `git add . && git commit -m 'fix(gitignore): add angular cache'`. Making sure to note what was staged. – S. Taylor Nov 24 '21 at 16:50
  • 1
    @S.Taylor Perfect, sounds good. I have included your comment in the answer for more visibility. – VonC Nov 24 '21 at 16:53
4

For me, the problem still persisted,

I reconfigured the git in the following way:

  1. copy the configuration (.git/config)
  2. delete the .git folder
rm -rf .git
  1. initialize the git
git init 
  1. paste the old configuration (p.1) in the new git config file (.git/config)

  2. in .gitignore add line (for more details : angular-starter/.gitignore ):

node_modules
.angular/cache
  1. Add files and commit
git add . && git commit -m 'update'
  1. for avoiding to overwrite the previous commit, push in new branch
git push -f origin HEAD:<new_branch_name>
  1. push by overwriting (forcing causes loss of old commits),
git push -f origin HEAD:main
  1. or
git push -f origin HEAD:master
  1. in general
git push -f origin HEAD:<branch_name>
Nitsh
  • 79
  • 3
  • This one actually worked.. For me even though i ignored the files and did rm cached, which showed the angular/cache folder files were removed from GIT commit, it still was pushing the whole set.. With these steps mentioned, it worked perfectly – smilu Aug 30 '22 at 12:09