I want to track my frameworks with lfs by a smart way. So this is my setting for git lfs:
*.framework/Versions/A (.gitattributes) */*.framework/Versions/A (.gitattributes) */{*.framework}/Versions/A (.gitattributes)
But it doesn't work. When I run
"git add ."
there's no files tracked by lfs.
How to fix that. Thank you!
You should use Git LFS if you have large files or binary files to store in Git repositories. That's because Git is decentralized. So, every developer has the full change history on their computer.
Git LFS (Large File Storage) is a Git extension developed by Atlassian, GitHub, and a few other open source contributors, that reduces the impact of large files in your repository by downloading the relevant versions of them lazily.
Navigate to git-lfs.github.com and click Download. Alternatively, you can install Git LFS using a package manager: To use Homebrew, run brew install git-lfs . To use MacPorts, run port install git-lfs .
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.
You can follow the next steps to add all frameworks to the git lfs:
brew install git-lfs # install via homebrew git lfs install # initialize lfs for yor repo git lfs track ios-app/Frameworks/*.framework/**/* # track all frameworks in your project git add --all # stage git commit -m "Added files to git lfs" # commit git lfs ls-files # check that files are tracked
Eventually you should get the next result:
9ee501fdc8 * ios-app/Frameworks/Lottie.framework/Headers/Lottie-Swift.h 8fa3ecc835 * ios-app/Frameworks/Lottie.framework/Info.plist 4a870aa4cc * ios-app/Frameworks/Lottie.framework/Lottie
Take into account that this will not convert any pre-existing files to Git LFS (from other branches or in your prior commit history). To do that, use the git lfs migrate command:
git lfs migrate import --include='ios-app/Frameworks/*.framework/**/*' --everything
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