跳至主要内容

What is git-lfs and how to convert existing repo

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.

  1. Convert or migrate to git-lfs repo.
  2. 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

评论

此博客中的热门博文

Use MobaDiff with git difftool

Recently there's an activity in IT that forces the deletion of all unauthorized softwares from all work machines. Unfortunately, kdiff3 is one in the list. As it is generally okay to use vimdiff as an alternative for kdiff3, A gui tool is better suited for desktop workflows. Known that MobaXterm is shipping a gui diff tool named MobaDiff. But it only appears in the windows right click context menu. Find the real application name takes me some time to search in the windows registry. "MobaRTE.exe", which is the one invoked by HKCR\*\shell\MobaDiff. And it was invoked with "-contextdiff" switch to show MobaDiff UI, while when the switch is "-contextedit" it shows MobaTextEditor. Too bad that the "-contextdiff" switch do not support pre-image post-image as other diff tool did, which effectively made it unable to be used as a command line diff utility. Also MobaTech did not mention anything in their document of this Mob...

Emacs 26.2 windows Hunspell setup

 Hunspell failed with default setup With my shining new emacs26.2 setup, I am happy until trying to `M-$’ on a word. I got following error message, it used to be work by just set ispell program to hunspell. Starting new Ispell process hunspell with default dictionary... split-string: Wrong type argument: stringp, nil After some check in my customization setting. nothing found. install a copy of hunspell dictionary At first I think it was caused by no hunspell dictionary. I downloaded en US and en CA hunspell dictionary from wordlist.sf.net project. After put the .aff and .dic files into C:directory I’ve also made a symbolic link from en US ones by running the `mklink’ tool: mklink default.aff en_US.aff mklink default.dic en_US.dic Err… hunspell does not work, still. Time to read code Dig into ispell.el I suprisingly find there’re lots of hunspell specific logic. Originally I was thinking hunspell support involves no elisp work. Acturally ispell did many work to de...

XEmacs 21.5 beta 35 "kohlrabi" has been released.

If you are an old XEmacs user, you may feel happy to see this from https://www.xemacs.org/.    After ten years, XEmacs released a new version 21.5. So there's still many people cares about XEmacs. The XEmacs' source repo have been moved from altassian Bitbucket to https://heptapod.net/. As Bitbucket have been dropped Mercurial support many years ago.