These days we have dependency managers to download all dependencies to the project which keeps our project very light in the source control… but we can still encounter a situation where a third party library is provided as a compiled framework or library file, which we have to include in project and add to source control.

Recently we have encountered a problem we had a *.a library which grown over 100 MB over time and Github started rejecting the push and below is what we did

We had this problem with iOS project so solution is for MAC

From the machine of the person who is pushing the code

Step1: Install brew

Step 2: brew install git-lfs

Step 3: Go to the root folder of the repo where the .git is located and hit git lfs install (you may want to do this for every repository you have)

Step 4: Select file type eg: for us it was *.a , type the command git lfs track “*.a” (You may be asked to authenticate, provide the credentials when asked, if you have enabled 2 factor auth, then it can be difficult I haven’t figured it out)

Step 5: Type in git add .gitattributes

Step 6: If it is a new file do git add filename

Step 7: Commit and push

How to pull?

Normal pull wont bring in the large files so, if you want to pull in another device please follow Step 1–3 and then go the root of repository

  1. Once you do a normal pull, do git lfs pull

This will bring the big file also… and thats it.