Reputation: 664
I want to push my NextJS Project to GitHub but I always get an error that says my .next/cache folder exceeds GitHub's file size limit.
I tried to solve this by adding the next folder to the .gitignore file.
This is my .gitignore file
node_modules
next
.env
Then I followed this steps:
.gitignore
filegit rm -r --cached .
command.git add .
commandgit commit -m "Commit message"
or just git commit
or continue working.git push
But it still didn't work.
Error that I got
remote: error: File .next/cache/webpack/client-development/32.pack is 122.93 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File .next/cache/webpack/client-development/71.pack is 126.09 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File .next/cache/webpack/client-development/9.pack is 155.84 MB; this exceeds GitHub's file size limit of 100.00 MB
Did I write something wrong in my .gitignore file or is there another problem?
Thank's for helping out!
Upvotes: 7
Views: 14725
Reputation: 1729
The only thing that worked for me was this:
git rm --cached .next/ -r
Then checking git status
git status
Check how far ahead you are
On branch master
Your branch is ahead of 'origin/master' by 8 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
Then run the following appending how far ahead you are
git reset HEAD~8
Then:
git add .
git commit -m "bug fix"
git push -u origin main
Upvotes: 4
Reputation: 9476
I strongly suspect that the problem is that the files may have been deleted, but they still exist in the history of the repository between when you last pushed and now. A file that's committed and then deleted in a later commit still exists in the repository history.
In order to resolve the issue you'll therefore need to remove them from the repository history entirely. https://docs.github.com/en/github/managing-large-files/working-with-large-files/removing-files-from-a-repositorys-history provides some guidance on doing this.
Upvotes: 3