
gittech. site
for different kinds of informations and explorations.
Lfs-auto-track: Automatically run `Git lfs track` to track large files
LFS Auto Track · 

lfs-auto-track
If the files bigger than the size (you can configure, check the usage part), when commit, automatically run git lfs track
files.
Usage
Step 0: prepare
make sure use husky
and lint-staged
in the project, and run git lfs install
Step 1: install
npm i lfs-auto-track -D
Step 2: Configure
Add lint-staged
script in package.json
{
"name": "module-name",
...
"lint-staged": {
"*": [
"lfs-auto-track 'image,video,audio:100;*:1024'"
],
}
...
}
Configuration means
'image,video,audio:100;*:1024'
means if mimetype is image/video/audio files's size bigger than 100 KB, and others files bigger than 1024 KB, these files will add to.gitattributes
with run commandgit lfs track
automatically;
'*:1024'
means any files size bigger than 1024 KB when commit, these files will add to.gitattributes
with run commandgit lfs track
automatically;
The size units support
B
/KB
/MB
/GB
, default isKB
'jpg,png,gif:1MB'
means files with extensionjpg
orpng
orgif
size bigger than 1 MB when commit, these files will add to.gitattributes
with run commandgit lfs track
automatically.
Examples
- Check the repo source code (
package.json
/imgs/
) This file should be store in LFS
Some questions
- How to upload the large file after track?
git lfs push --all origin
- How to clone the project without download the large file?
GIT_LFS_SKIP_SMUDGE=1 git clone THE_REPO_URL
- How to download the large files?
git lfs pull