47

Currently when I try to push to a Git repo, I am getting the following error.

remote: error: GH001: Large files detected.
remote: error: Trace: 7bbfe5c1099cfe679aa3cd1eee13e10a
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File e3384023be667de7529538b11c12ec68.201307290946.sql.gz is 125.37 MB; this exceeds GitHub's file size limit of 100 MB

I have gone through and made sure that this file does not exist in the directory, and have done git add -u. We have tried to prune the branch but this doesn't work as it can't find the file to delete.

2
  • no result through commandline with find --name "*.sql.gz" perhaps you have the file in a phpmyadmin directory or some temp directory?
    – Luceos
    Commented Nov 8, 2013 at 11:59
  • That didnt seem to find anything either.
    – Dave Sims
    Commented Nov 8, 2013 at 12:06

8 Answers 8

48

It is possible that you are pushing several commits, one of them including a large file, and another more recent one removing that file.

2020-2022:

Use git filter-repo (python-based, to be installed first)

And use some content-based filtering:

If you want to filter out all files bigger than a certain size, you can use --strip-blobs-bigger-than with some size (K, M, and G suffixes are recognized), e.g.:

git filter-repo --strip-blobs-bigger-than 10M

Original answer, using obsolete tools like git filter-branch or BFG:

In any case, you can try, as explained in "Fixing the “this exceeds GitHub’s file size limit of 100 MB” error", a filter-branch (if you know the name/path of the large file that you can't see)

git filter-branch --index-filter 'git rm --cached --ignore-unmatch e3384023be667de7529538b11c12ec68.201307290946.sql.gz' <sha1>..HEAD

Or, if you don't know but want to get rid of any large file (say > 90MB), you can use the BFG repo cleaner

bfg --strip-blobs-bigger-than 90M  my-repo.git

That will track for you that elusive large file in your repo history and remove it.
Note that you will have to do a git push --force after that, because the history of the more recent commits will have been modified.
If others already cloned your repo before, a bit of communication is in order to warn them.

7
  • 1
    Filter branch worked perfectly, cheers for that! All back up and running now.
    – Dave Sims
    Commented Nov 10, 2013 at 12:00
  • 1
    Could you clarify what merge-point..HEAD means in your first suggestion? I tried to use it and git said it didn't know what that meant.
    – wandadars
    Commented Feb 10, 2017 at 21:13
  • 1
    @wandadars that was coming from the article thisprogrammingthing.com/2013/…. I replaced "merge-point" by <sha1>: you are meant to filter from that SHA1 (excluded) up to HEAD (included), so take the oldest commit with the file to remove, takes its parent and you will have the sha1 I refer to.
    – VonC
    Commented Feb 10, 2017 at 23:53
  • removing the ` <sha1>..HEAD` was the only way this worked for me. the error I was getting was bash: sha1: No such file or directory Commented Aug 24, 2018 at 7:43
  • @ThomasMatthew But... <sha1> is supposed to be replaced by an actual commit SHA1.
    – VonC
    Commented Aug 24, 2018 at 7:45
31

In my case I fixed it with this link:

GitHub Help | Working with large files

Notice where it says giant_file

$ git filter-branch --force --index-filter \
  'git rm --cached --ignore-unmatch giant_file' \
  --prune-empty --tag-name-filter cat -- --all

$ git commit --amend -CHEAD

$ git push
0
12

Remove file using filter-branch

git filter-branch --tree-filter 'rm -rf your/file/path/task.txt' HEAD

make sure you must add rm -rf

after that push the code

git push origin master -f
0
6

In case you have several large files you need to run another command:

git filter-branch --index-filter 'git rm --cached --ignore-unmatch largfile1'
git filter-branch --index-filter 'git rm --cached --ignore-unmatch largefile2'
Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f

You need to run

git update-ref -d refs/original/refs/heads/master

Then you can run git filter-branch command

Hope this helps you

1
  • Perhaps someone else is aware of a general unmatch command that applies to files over a certain size, but giant_file did not work for my two files. I had to apply the filter-branch command to each of my two large files (running update-ref in between). Thanks to @keminzhou 's suggestion I was able to resolve my large file double commit issue. Commented Jul 3, 2018 at 17:05
3

Following are the steps with which you can push objects larger than 100MB:

  1. Install git-lfs instructions can be found at https://git-lfs.github.com/

  2. Let say you have *.jar files that are larger than 100 MB, then you run git lfs track "*.jar. You should see something like

    Tracking "*.jar"

  3. git add .

  4. git push -u origin master

You should see something like:

Uploading LFS objects:  89% (398/447), 864 MB | 1.8 MB/s
2
  • 1
    I've been working on removing multiple larger files from my previous gits and tried multiple ways, this one is the easiest way, thank you!
    – uyghurbeg
    Commented Dec 6, 2021 at 14:38
  • Hey! I know this is old but I have a root directory with a zip file (245 MB) in a folder called downloads. When using git-lfs track *.zip, it shows that it's tracking. When I use git add . then git push -u origin main, it'll try to commit the large file then say File [name].zip is 245.90 MB; this exceeds GitHub's file size limit of 100.00 MB even though git-lfs is set up. Can you help? Commented Feb 7, 2022 at 19:00
2

First the unstaged commits need to be resolved. Use git status

Commit these files

git status -s | grep D

Commit these files

git status -s | grep M

and then run this

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch path-to-large-file' --prune-empty --tag-name-filter cat -- --all

Once the above command is executed, the history of commits will be iterated to find the large file and will be removed.

1
  1. Download file from:https://git-lfs.github.com/
  2. Commands:

a. git lfs install

b. git lfs track "*.psd"

c. git add .gitattributes

  1. Commit and push.
0

I addressed the issue by creating a new branch and adding a .gitignore file to exclude Terraform files. After committing these changes, I uploaded the repository again. The problem arose from Git attempting to upload a massive file when running the Terraform project. To resolve this, I created a new repository, added a .gitignore file to ignore the folder containing Terraform files. This ensured that only the essential project files, relevant to my work, were uploaded to Git, avoiding unnecessary large file uploads.

Do you get what I mean?

1
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jan 30 at 0:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.