I'm facing an issue while trying to push a large file (src/data/indonesia-cities.json, size: 139.64 MB) to GitHub. I understand that GitHub has a 100 MB file size limit, so I tried using Git Large File Storage (Git LFS) to handle it.
Steps Taken:
git lfs track "src/data/indonesia-cities.json".gitattributes and committed the changes.
Here's the sequence of commands I used:git lfs install
git lfs track "src/data/indonesia-cities.json"
git add .gitattributes
git commit -m "Track large files with Git LFS"
git push
Despite following these steps, I'm still getting an error message when trying to push to GitHub:
remote: error: File src/data/indonesia-cities.json is 139.64 MB; this exceeds GitHub's file size limit of 100.00 MB

What I've Tried:
How can I resolve this issue and successfully push the large file to GitHub using Git LFS?
I managed to solve this issue by using Git LFS's migrate command. Here are the steps to resolve the problem:
Step 1: Install Git LFS First, if you haven't already installed Git LFS, you can do so with the following command:
git lfs install
Step 2: Use git lfs migrate To move the large file into Git LFS, use the migrate command as follows:
git lfs migrate import --include="src/data/indonesia-cities.json"
This will rewrite your Git history to move the large file into LFS.
Step 3: Add and Commit Changes Now you should stage and commit the .gitattributes file and the large file itself:
git add .gitattributes src/data/indonesia-cities.json
git commit -m "Migrate large file to Git LFS"
Step 4: Push to Remote Repository Finally, push your changes to your remote repository:
git push origin your-branch-name
Note: Be cautious when using history rewriting commands like git lfs migrate, especially on shared repositories. Always backup your repository and inform your collaborators to re-clone after such changes.
Source: https://docs.github.com/en/repositories/working-with-files/managing-large-files/moving-a-file-in-your-repository-to-git-large-file-storage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With