Git: Solving ‘Large files detected…’ warning

k w
2 min readFeb 16, 2020

--

Recently I was working on my onsite project that involved uploading large files ( > 50 MB). When I was trying to push changes into my remote origin branch I received the following message:

Warning: Large file detected.

Removing the file from your local repository will not help because the file itself left a trace in the history.

There are several ways to fix the problem. You may use Git Large File Storage (git-lfs.github.com) or use suggested commands on GitHub help page (help.github.com/en/github/managing-large-files/removing-files-from-a-repositorys-history).

I used the rebase command which can be used to rewrite the history of a repository. Remember to have a backup of the repository you are about to run the command on in case something goes wrong.

  1. Look into your history to see which file might have violated the 100MB hard limit. In my case it was the following mp4 file:
    git log — name-status — all
Large file added in commits.

2. Find first commit id preceding the commit which added the file. In my case: 7c0a5fae

3. Run:

git rebase -i <commit id>In my case git rebase -i 7c0a5fae

Change ‘pick’ to ‘edit’ for all commits touching your offensive file.

4. For every commit you selected in the previous step, git rebase will recreate a snapshot and allow you to edit that commit. Keep repeating steps below until your rebase is completed:

git rm <your file> 
git commit --amend # this will overwrite the original commit
git rebase --continue

Note: you might get conflicts as you continue with your rebase, resolve them the usual way.

5. After removing from you history all files > 50MB, you can finally push!

6. Success!

--

--

No responses yet