lfs-auto-track streamlines the management of large files in Git by automatically executing git lfs track during pre-commit hooks. Designed to seamlessly integrate with husky and lint-staged, it ensures that large files are handled properly based on user-defined configurations, simplifying the workflow for developers.
lfs-auto-track is a utility that automates the tracking of large files in a Git repository using Git LFS (Large File Storage). This tool integrates seamlessly with pre-commit hooks to ensure that specified large files are automatically added to .gitattributes, streamlining the process of managing large assets in a project.
Features
- Automatic Tracking: Automatically executes 
git lfs trackfor large files above a predetermined size during a commit, minimizing manual intervention. - Flexible Configuration: Users can configure file size limits and types through the 
lint-stagedsetup inpackage.json, allowing for customized tracking behavior based on project needs. 
Usage Instructions
Before Getting Started
Ensure that your project is using husky and lint-staged, and that Git LFS is installed:
git lfs install
Installation
To install lfs-auto-track, run the following command:
npm i lfs-auto-track -D
Configuration
To set up automatic tracking, add a lint-staged script in your package.json:
{
  "name": "module-name",
  "lint-staged": {
    "*": [
      "lfs-auto-track 'image,video,audio:100;*:1024'"
    ]
  }
}
Configuration Breakdown
- The configuration string 
'image,video,audio:100;*:1024'specifies that image, video, and audio files larger than 100 KB will be tracked, while any other file types larger than 1024 KB will also be tracked. - Similarly, 
'jpg,png,gif:1024'would track files with those specific extensions if they exceed 1024 KB. 
Example Usage
Check the source code in the repository for an illustration of how files should be managed:
- Example Image which should be stored in LFS.
 
Frequently Asked Questions
- How to upload large files after tracking?
 
git lfs push --all origin
- How to clone the project without downloading large files?
 
GIT_LFS_SKIP_SMUDGE=1 git clone THE_REPO_URL
- How to download the large files?
 
git lfs pull
Overall, lfs-auto-track simplifies and automates the management of large files in Git repositories, enhancing workflow efficiency and project organization.
No comments yet.
Sign in to be the first to comment.