What is git-lfs
According to its name, git-lfs is git-large-file-storage. Is a git plugin which replace large file to their corresponding text pointers in git repo.
This way it accelerates git fetch process by only download needed large file objects.
Why git-lfs?
Git service provider such as GitHub and bitbucket are both activated the git-lfs on their service.
Actually, github also setup a hook that will reject commits with large binary files.
If you have a legacy git repository and want to host it on GitHub, you must make sure there's no large binary files ever checked into your repo in the past.
What if you got a poisoned repo full of large binary files?
There are no many options to choose from when you are in this situation.
- Convert or migrate to git-lfs repo.
- Drop the history, as huge git-lfs do cost money. Both github and bitbucket set 1GB limit on their free git-lfs storage capacity.
Enable git-lfs in new repo and Convert existing repo to git-lfs repo with git
There's an offical solution to this task, on git-lfs homepage. The procedure to enable git-lfs is very simple, in nutshell contains following steps:
cd <REPO> git lfs install git lfs track "*.psd"
migration is alo provided in its dedicated page, as shown bellow:
git lfs migrate info git lfs migrate import --include="*.mp3,*.psd"
Convert existing repo to git-lfs repo with bfg
The full name of the utility is bfg-repo-cleaner. As the name stated it can do all kinds of git repo cleanup tasks. One of its feature is to convert the git history to git-lfs.
The tool runs very fast, and will present a nice looking ASCII report for the operation.
The procedure consists of only one command as:
java -jar <path to>bfg-x.x.x.jar --convert-to-git-lfs "*.{png,mp4}" --no-blob-protection <repo-name>.git
References
- https://git-lfs.github.com/
- https://confluence.atlassian.com/bitbucket/use-git-lfs-with-existing-bitbucket-repositories-829078749.html
- https://confluence.atlassian.com/bitbucket/use-bfg-to-migrate-a-repo-to-git-lfs-834233484.html
- https://github.com/git-lfs/git-lfs/wiki/Tutorial
- https://help.github.com/en/github/setting-up-and-managing-billing-and-payments-on-github/about-billing-for-git-large-file-storage
- https://bitbucket.org/product/pricing
评论
发表评论