43

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.

Null
  • 1,950
  • 9
  • 30
  • 33
Dave Sims
  • 735
  • 1
  • 6
  • 11

7 Answers7

47

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Filter branch worked perfectly, cheers for that! All back up and running now. – Dave Sims Nov 10 '13 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 Feb 10 '17 at 21:13
  • 1
    @wandadars that was coming from the article http://www.thisprogrammingthing.com/2013/fixing-the-this-exceeds-githubs-file-size-limit-of-100-mb-error/. I replaced "merge-point" by : 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 Feb 10 '17 at 23:53
  • removing the ` ..HEAD` was the only way this worked for me. the error I was getting was `bash: sha1: No such file or directory` – Thomas Matthew Aug 24 '18 at 07:43
  • @ThomasMatthew But... `` is supposed to be replaced by an actual commit SHA1. – VonC Aug 24 '18 at 07:45
  • How can I do this in Visual Studio Code? thanks – Dave Jan 06 '22 at 17:37
  • @Dave Note: I have edited the answer to reference the current tool to use (`git filter-repo`). Second, there is no real integration with VSCode, beside opening a terminal in VSCode and typing the `git filter-repo` command. – VonC Jan 06 '22 at 18:56
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
user9869932
  • 6,571
  • 3
  • 55
  • 49
10

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
Abdul Basit
  • 953
  • 13
  • 14
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

Kemin Zhou
  • 6,264
  • 2
  • 48
  • 56
  • 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. – Abe Hoffman Jul 03 '18 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
Vishrant
  • 15,456
  • 11
  • 71
  • 120
  • 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 Dec 06 '21 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? – WhatTheClown Feb 07 '22 at 19:00
1

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.

SuperNova
  • 25,512
  • 7
  • 93
  • 64
0
  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.
Pran
  • 121
  • 3