103

I have some csv files that are larger than github's file size limit of 100.00 MB. I have been trying to use the Git Large File Storage extension.

https://git-lfs.github.com/

From LFS - "Large file versioning- Version large files—even those as large as a couple GB in size—with Git."

I have applied the following on the folders of concern:

git lfs track "*.csv"

However, when I push:

remote: error: File Time-Delay-ftn/Raw-count-data-minor-roads1.csv is 445.93 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File Time-Delay-ftn/Raw-count-data-major-roads.csv is 295.42 MB; this exceeds GitHub's file size limit of 100.00 MB

When I look at the folder in question:

-rw-r-----   1 user  staff    42B 23 Oct 12:34 .gitattributes
-rw-r--r--   1 user  staff   1.3K 19 Oct 14:32 DfT_raw_major_manipulation.py
-rw-r--r--   1 user  staff   1.2K 16 Oct 15:08 DfT_raw_minor_manipulation.py
drwxr-xr-x  21 user  staff   714B 22 Oct 11:35 Driving/
-rwxr-xr-x@  1 user  staff   295M 19 Oct 14:47 Raw-count-data-major-roads1.csv*
-rwxr-xr-x@  1 user  staff   446M 16 Oct 14:52 Raw-count-data-minor-roads1.csv*

when I vim the .gitattributes file you can see the lfs setup:

*.csv filter=lfs diff=lfs merge=lfs -text

What am I doing wrong?

UPDATE

When I query

git lfs ls-files

I get nothing returned. This indicates that despite the .csv filter being successfully applied to the .gitattributes file the csv files are not being picked up by lfs

LearningSlowly
  • 8,641
  • 19
  • 55
  • 78
  • “You will not be allowed to push files larger than 100 MB.” – [GitHub.com on *Working with large files*](https://help.github.com/articles/working-with-large-files/) – Gumbo Oct 25 '15 at 14:45
  • 3
    Could you not zip them or something instead to decrease size? – Henry Oct 25 '15 at 15:29
  • 4
    @Gumbo That document also says "consider introducing Git Large File Storage (Git LFS)". This appears to be what is asked about. Following that link the docs say "It's the ideal solution for pushing files to GitHub that are larger than 100 MB" – Nathan Buesgens Oct 26 '15 at 20:47
  • @natb1 - yes, if you read the documentation - that is exactly what it says. – LearningSlowly Oct 27 '15 at 07:49
  • @Henry. Thanks - I tried that. Still too large in some cases – LearningSlowly Oct 27 '15 at 07:49
  • Maybe you're not using lfs well? This is the same message that appears when you want to push a file larger than 100MB in a regular repository https://help.github.com/articles/conditions-for-large-files/#100-mb-push-limit – Jepessen Oct 27 '15 at 09:01
  • Hello, I added to my gitignore the files I don't need that are the reason I exceed the 100mb limit, I also delete the cached files using git rm -r --cached but I still get the message. – Alejandro Jun 15 '22 at 04:11

12 Answers12

148

Since Git LFS 2.2.0 you can use git lfs migrate command. In your case it would look this way:

git lfs migrate import --include="*.csv"

After this, you should be able to push changes into origin.

More information about git lfs migrate is available on Git LFS 2.2.0 release note site and git-lfs-migrate command documentation.

pitagoras3
  • 1,988
  • 2
  • 14
  • 18
  • 1
    Worked Like a charm after trying all the above answers, issue caused by Zoom. – Lalit Fauzdar Mar 04 '21 at 13:05
  • 11
    This is a more modern answer, should be bumped to the top. For anyone reading this, try this before any of the above answers. – Gunner Stone Mar 18 '21 at 06:06
  • 2
    If you get the `not a valid git command` error, make sure to install lfs. A how to guide for all platforms can be found here. - https://stackoverflow.com/a/48734334/2480714 – PGMacDesign Apr 24 '21 at 04:16
  • Can anyone explain --include flag for me? and what is the difference between --include and --exclude? Thanks in advance. – gia huy Oct 12 '21 at 03:56
  • Can I specify remote in this command? Because I have two remotes in my repo and I can only access one of them at this time(The `LAN` one is not accessible). – K.F May 07 '22 at 01:52
  • This works fine with me with mp4 files – Two Aug 04 '23 at 13:43
35

i had same issue, but it's resolved using filter-branch

git filter-branch --tree-filter 'rm -rf path/to/your/file' HEAD

it'll take some time if you have big project, then push it

git push

Jignesh Sanghani
  • 602
  • 6
  • 12
33

Simply adding git-lfs configuration to an existing repository will not retroactively convert your large files to LFS support. Those large files will remain in your history and GitHub will refuse your pushes.

You need to rewrite your history to introduce git-lfs to your existing commits. I recommend the BFG repo cleaner tool, which added LFS support recently.

You should be able to convert historical usage of your CSV files by:

$ java -jar ~/bfg-1.12.5.jar --convert-to-git-lfs '*.csv' --no-blob-protection
Roberto Tyley
  • 24,513
  • 11
  • 72
  • 101
Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
  • 1
    thanks! indeed. However, I am not having much luck with bfg. I did brew install bfg. I have checked the file path but I am getting Error: Unable to access jarfile /usr/local/cellar/bfg-1.12.5.jar – LearningSlowly Nov 10 '15 at 16:57
  • 1
    @LearningSlowly - I'm not familiar with brew. I would think that you would only need to download the jar from GitHub and run it per the instructions. – Edward Thomson Nov 11 '15 at 17:43
  • I have a further issue - but this definitely solved the problem I had here! Many thanks – LearningSlowly Nov 12 '15 at 12:43
  • Tried the bfs approach for about 3 hours. It doesn't seem to do anything: Found 133 commits Cleaning commits: 100% (133/133) Cleaning commits completed in 216 ms. BFG aborting: No refs to update - no dirty commits found?? Then makes anti trump comments, which I don't care about. I do care that its unintuitive and didn't work – AlexK Dec 07 '19 at 00:42
20

I had this error:

remote: error: File client/static/static-version/20171221_221446.psd is 223.61 MB; this exceeds GitHub's file size limit of 100.00 MB

And because I already removed this file from this folder, created .gitignore file and tried to commit couple times, I didn't know that it was cached, I could not push to github. In my case helped:

git filter-branch --index-filter 'git rm --cached --ignore-unmatch client/static/static-version/20171221_221446.psd'

Where I placed full file path(from error above) to remove it from cache. After that, push was made successfully

Yarik
  • 742
  • 8
  • 13
  • 1
    Thank you! this solved my issues but in the git help I couldn't find any mention about this – Omiod Dec 02 '21 at 16:34
20

I have faced the same problem while some of my csv file was merged in previous commit and github rejected my push. Later I found this command which worked for me.

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch fixtures/11_user_answer.json'
# for my case
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch tensorflow.csv'

filter-branch rewrites commit history of the mentioned branches.

--index-filter is filter for rewriting the index

git rm --cached --ignore-unmatch tensorflow.csv completely forgets the tensorflow.csv file from all commits it is present.

Original post link

documentation for filter-branch

avijit
  • 805
  • 2
  • 12
  • 21
  • 1
    How do I chain multiple files? Its complaining I have several that I need to remove from history – Potion Oct 05 '20 at 23:00
  • what is the extension type? If all are csv, then try *.csv. Or the specific extension type you want to remove. – avijit Oct 06 '20 at 04:49
  • this deleted my big file locally – gl3yn May 14 '21 at 12:09
  • " With git rm --cached you stage a file for removal, but you don't remove it from the working dir. The file will then be shown as untracked. " for details https://stackoverflow.com/a/38001958/4374376 – avijit Nov 01 '22 at 21:14
17

I hit the same problem yesterday and cracked it. I was unable to push, and it appeared that none of my big files were in lfs.

There is probably a better way, but this worked for me. I have a large repo with 2.5 gigs of data.

I setup a new repo then setup lfs in it. git lfs init

I then configured my various file types git lfs track "*.pdb" git lfs track "*.dll" I then commmited my changes and pushed.

I then added my big files. I used sourcetree, and in the output notes it would state for the big files matching my wildcards that it was committing tiny txt file instead. (sorry, I didn't record these, but it should be obvious).

Then I pushed, and I saw 'skipping files', and the push succeeded quickly.

so the problem is probably trying to add files to lfs that are already in your history. You can only add new files. You can probably clean your repo of these files.

Note: I did find that quite a few files that matched my wildcards were not picked up by lfs. Similar files in different folders were picked up, but not all. I tried explicitly adding these files using the full path. git lfs track "Windows/bin/myBigFile.dll" but that didn't help either. In the end I gave up due to time constraints.

You should also check your storage limit with gitHub. I purchased the extra 50gig to cover my requirements.

Cloning the repo now downloads the files separately and everything is finally working well.

Philip Taylor
  • 521
  • 5
  • 11
  • Thanks! A viable solution. However, I think using the BFG tool is the best way forward. I ended up in the same boat though, had to purchase 50GB ;) – LearningSlowly Nov 16 '15 at 15:33
  • The important part here is to update your .gitattributes (git track <>) in a separate commit from adding the large files. – diedthreetimes May 19 '19 at 05:30
16

Try the following command in your terminal. It will resolve the lfs issue.

git lfs migrate import --include="*.csv"
Codemaker2015
  • 12,190
  • 6
  • 97
  • 81
9

This solution worked for me on Ubuntu 20.04

Install the Git Large File Storage (git-lfs)

sudo apt-get install git-lfs
git-lfs install

To convert any pre-existing files to Git LFS, such as files on other branches or in your prior commit history us the git lfs migrate command

git lfs migrate import --include="*.ipynb" 

Select the file types to be tracked

git lfs track "*.ipynb"

update the gitattributes

git add .gitattributes

Now push to the git git commit -m "commit message" git push

And for the storage and bandwidth usage please refer

https://docs.github.com/en/github/managing-large-files/versioning-large-files/about-storage-and-bandwidth-usage

Joaquim
  • 380
  • 4
  • 10
5

If you know which commit introduced the large commit, you could also try squashing that commit with the subsequent commits that introduced Git LFS.

For example, if the large commit was three commits ago (as revealed by git status), you could do the following:

git rebase -i HEAD~3

Then, replace all "pick" usages after the first one with "squash" in the interactive dialog.

Then,

git push origin --force
Eric
  • 297
  • 3
  • 7
0

I also, faced this error.I installed LFS did the following steps

enter image description here

And this is what I did:

Step 1: Get the commit ID suppose "3540ea5c94ccd63d40" (commit ID that contain large file)

Step 2: git rebase -i HEAD~1

Step 3: Replace all "pick" to "squash" in the interactive dialog.

Step 4: Press esc and then save file by :wq.

enter image descrip
tion here

Step 5: the run git push origin BRANCH_NAME

And it's solved

enter image description here

Shubham Verma
  • 8,783
  • 6
  • 58
  • 79
-1

This may be help you enter image description here

Click-OriginalWebPage

Only install lfs to a exist repo may be not enough. Your may also change the commit history. Hope this is work for you .

linjiejun
  • 1,468
  • 15
  • 22
-3

It looks like you haven't initialised git-lfs. Try to type

git lfs init

Source: Installing Git LFS

hombit
  • 131
  • 1
  • 9