Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use GIT LFS to track iOS frameworks?

Tags:

git

ios

git-lfs

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!

like image 314
vietstone Avatar asked Feb 16 '16 10:02

vietstone


People also ask

When should you use git LFS?

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.

What is the purpose of git LFS?

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.

How do I get git LFS on Mac?

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 .


2 Answers

Important: To successfully get Git LFS working, the file may not already be in your Git history.

Mandatory steps:

  1. Install Git LFS via brew (or mac ports.. )

    brew install git-lfs

  2. Initialize LFS inside jour local Git repo. Otherwise your commands will have no effect.

    git lfs install

// Updated pre-push hook. Git LFS initialized.

  1. 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

  1. Add all the files including the new generated ".gitattributes"

    git add .

  2. Commit changes

    git commit -m "added lfs binary"

  3. Now verify the file is properly tracked by LFS

    git lfs ls-files

// 604bd36eb5 * MyProject/Libraries/opencv2.framework/Versions/A/opencv2

  1. 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.

like image 186
ehrpaulhardt Avatar answered Sep 21 '22 16:09

ehrpaulhardt


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 
like image 23
sgl0v Avatar answered Sep 24 '22 16:09

sgl0v