Important: To successfully get Git LFS working, the file may not already be in your Git history.
Mandatory steps:
-
Install Git LFS via brew (or mac ports.. )
brew install git-lfs
-
Initialize LFS inside jour local Git repo. Otherwise your commands will have no effect.
git lfs install
// Updated pre-push hook. Git LFS initialized.
-
Do not track the iOS framework directly (eg. “opencv2.framework”) because macOS will treat it as a folder. Just track the one large binary file inside the framework.
git lfs track MyProject/Libraries/opencv2.framework/Versions/A/opencv2
// Tracking MyProject/Libraries/opencv2.framework/Versions/A/opencv2
-
Add all the files including the new generated “.gitattributes”
git add .
-
Commit changes
git commit -m "added lfs binary"
-
Now verify the file is properly tracked by LFS
git lfs ls-files
// 604bd36eb5 * MyProject/Libraries/opencv2.framework/Versions/A/opencv2
-
Push the commit and see that Git is uploading the large file first
git push
// Git LFS: (1 of 1 files) 3.54 MB / 87.34 MB
And you are done.