md added
Browse files- LARGER_FILES.MD +76 -0
LARGER_FILES.MD
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Quick summary — recommended approach
|
| 2 |
+
Use Git LFS to track large binary files (models, datasets, etc.). It replaces file contents in the Git history with small pointers and stores the real file content separately.
|
| 3 |
+
If the large file is already committed to history, use git lfs migrate to rewrite history and convert those file entries to LFS pointers (requires force-push).
|
| 4 |
+
Alternatives: GitHub Releases (for single large assets), external object storage (S3, Azure Blob) and store URLs in repo, or tools like git-annex/BFG for special workflows.
|
| 5 |
+
Below are step-by-step commands you can run in your environment (Linux, bash). Replace remote names and branch names as appropriate.
|
| 6 |
+
|
| 7 |
+
1) Install Git LFS
|
| 8 |
+
On Ubuntu/Debian:
|
| 9 |
+
|
| 10 |
+
sudo apt update
|
| 11 |
+
sudo apt install git-lfs
|
| 12 |
+
git lfs install
|
| 13 |
+
|
| 14 |
+
git lfs version
|
| 15 |
+
|
| 16 |
+
2) Track the file types you want in LFS
|
| 17 |
+
Decide which patterns to track. For your repo, track model files:
|
| 18 |
+
|
| 19 |
+
cd /root/MlOpsUbuntu/1_ai_model_deployment/1_3_Inference/HF/CTAIAnimalClassifierFastApi
|
| 20 |
+
git lfs track "animal-classification/**/model.keras"
|
| 21 |
+
git lfs track "*.h5"
|
| 22 |
+
git lfs track "*.pt"
|
| 23 |
+
git lfs track "*.onnx"
|
| 24 |
+
|
| 25 |
+
This creates or updates .gitattributes with the tracked patterns. Commit it:
|
| 26 |
+
|
| 27 |
+
git add .gitattributes
|
| 28 |
+
git commit -m "Add Git LFS tracking for model files"
|
| 29 |
+
|
| 30 |
+
3) Add and push new large files (new, not already in history)
|
| 31 |
+
If the large file isn't yet committed:
|
| 32 |
+
|
| 33 |
+
git add animal-classification/INPUT_model_path/animal-cnn/model.keras
|
| 34 |
+
git commit -m "Add model to LFS"
|
| 35 |
+
git push origin main
|
| 36 |
+
|
| 37 |
+
After this, model.keras content will be stored in Git LFS and the Git history will only contain a small pointer.
|
| 38 |
+
|
| 39 |
+
Note: GitHub has an LFS bandwidth and storage quota for free accounts; see GitHub LFS docs. For large models, consider external storage (S3) if quotas are insufficient.
|
| 40 |
+
|
| 41 |
+
4) Migrate already-committed large files into LFS
|
| 42 |
+
If model.keras (or other large files) are already committed and in your history, you must rewrite history to convert prior commits to use LFS pointers.
|
| 43 |
+
|
| 44 |
+
Important: This rewrites git history. Coordinate with teammates; everyone must re-clone or reset their local clones after a force-push.
|
| 45 |
+
|
| 46 |
+
Example commands:
|
| 47 |
+
# Make sure you have a backup or are on a clone you can force-push from
|
| 48 |
+
git lfs install
|
| 49 |
+
|
| 50 |
+
# Convert all files that match the pattern to LFS across all branches and tags:
|
| 51 |
+
git lfs migrate import --include="animal-classification/**/model.keras,*.h5,*.onnx,*.pt" --everything
|
| 52 |
+
|
| 53 |
+
# Or narrower: only the main branch
|
| 54 |
+
git lfs migrate import --include="animal-classification/**/model.keras" --include-ref=refs/heads/main
|
| 55 |
+
|
| 56 |
+
# Force-push updated branches (example for main)
|
| 57 |
+
git push --force --all origin
|
| 58 |
+
git push --force --tags origin
|
| 59 |
+
|
| 60 |
+
What this does: rewrites commits to replace large blobs with LFS pointers and uploads blobs to the LFS storage during the migrate/import step.
|
| 61 |
+
|
| 62 |
+
Verification:
|
| 63 |
+
# Check that the file is now a pointer in git history
|
| 64 |
+
git ls-files -s | grep model.keras
|
| 65 |
+
|
| 66 |
+
# See LFS-managed objects
|
| 67 |
+
git lfs ls-files
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|