Converting Massive Git Repo's to LFS
I have an old website with a lot of large PDF files commited to my git repository. The repo is 300MB+ and is painful each time I need to clone it locally once in a blue moon to update it.
Converting your existing repository to LFS is actually super easy using the following.
Back up your repo in case all goes badly.
Install BFG Repo-Cleaner:
brew cask install bfg
Install Git LFS:
brew update && brew install brew install git-lfs
Clone your existing massive repository as a 'bare' repo:
git clone --mirror email@example.com:username/reponame.git
Move into that new directory:
Convert those massive PDFs and move to LFS:
bfg --convert-to-git-lfs '*.pdf' --no-blob-protection
Not sure what this does:
git reflog expire --expire=now --all && git gc --prune=now
Because we used –mirror, this will push ALL branches and tag: