7

I cloned my normal (non-lfs) repository to local drive. Now I want to add a file to it which is larger than 100MB and commit the change to the repository. I used following commands for this:

git clone ....

Then I copy that file with size >100MB that I want to add to repository. Lets say name of that file is "filename".

git lfs init
git lfs track "filename"
git add "filename"
git commit -m "commit message"
git push -u origin

And this fails with file size error message saying that files only sizes upto 100MB are allowed.

So how do I use git lfs in this case?

2
  • Does git lfs ls-files include your filename? Did you add .gitattributes?
    – Schwern
    Commented Nov 1, 2015 at 0:41
  • Yes it does and yes i added .gitattributes as well Commented Nov 1, 2015 at 5:19

2 Answers 2

6

You may check if that file was already tracked by standard git. In that case I suspect that the standard git would still be tracking it, not git lfs, thus imposing the 100MB limit.

If this applies to your case, try to migrate your existing file into a new repo:

git lfs migrate import --include="your.file"

and push the converted repository to a new one:

git push

PS: a similar phenomenon happens with .gitignore: ignoring a file a posteriori using .gitignore won't untrack it. In that case you must explicitly untrack it with git rm --cached <file>).

1
  • This solved my issue. I think I have tracked large files with regular git before I properly set up git lfs
    – Chenglu
    Commented Jun 15, 2019 at 2:44
4

Here I will take example where my folder name is data where my large files are stored.

Configure

In order add this folder to your repository, you have to configure the .gitattributes file. Here in my example I will do

$ cat .gitattributes
$ data/* filter-lfs

To track the file use:

$ git lfs track
Listing tracked paths
   data/* (<repo name>/.gitattributes)

Then you are good to go...

Commit

Use native git commands to add and commit the files.

$ git add data/
$ git commit -m "lf"

You will observe that file indexing will take only 1-2 seconds. To list all the lfs in your repo use:

$ git lfs ls-files

After everything you can push to remote:

$ git push -u origin master

This will take time to upload depending upon your internet speed.

You can refer these for more info:

2
  • 1
    What happens if one user has installed lfs and tracks some extension, but another user only has normal git? What happens if the normal-git user pushes a big file to the server?
    – dashesy
    Commented Jan 7, 2016 at 0:11
  • 1
    @dashesy in this case, for the other user who has no git lfs installed: when git clone,no error will pop up and the object file will be cloned, but the content of this file would be just the metadata of the real object instead of the object itself.
    – Zhong Hu
    Commented Oct 14, 2018 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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