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?
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>
).
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:
Git LFS Repository
Official Git LFS Website
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With