Git lfs easy to use tutorial

  References:

  https://zzz.buzz/zh/2016/04/19/the-guide-to-git-lfs/

  This essay briefly records the usage tutorial of git lfs, only the most commonly used parts are recorded, and the principle is explained for later reference.

  First explain the principle of git lfs, see the name: git lfs. lfs is Large File Storage, git lfs expands the capacity and functionality of git warehouse, so that a git warehouse can not only accommodate lightweight files (code, etc.), but also accommodate large multimedia files, such as models, data, etc. Files that cannot be handled by git clone and git pull can be easily managed by git lfs, and can be downloaded to the local at a high-speed transfer rate of tens of megabytes per second when needed.

  A typical usage scenario is the hugging face model library. The official gives such a use case:

  This use case is actually the simplest usage of lfs, that is: if your git supports lfs (this needs to be confirmed, it is a plug-in), then the first two lines of code should be able to crawl the file down at high speed.

  So if I don't want to download the large files in this warehouse first, and want to temporarily use pointers as placeholders for large lfs files, what should I do? Just configure the environment variable GIT_LFS_SKIP_SMUDGE=1.

  However, if there are redundant large files in a warehouse, for example, stable-dffusion has versions 512 and 768, and I only want the former, then using git clone directly may be too cumbersome. Is there a more elegant way? One way is recommended here:

git lfs install
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/prompthero/openjourney-v4

  Then use the lfs fetch exclude command to make git not pull what we don't want, such as:

git config lfs.fetchexclude "*.jpg,*.png,*.tga"

  The above command is actually stored in the .git/config file, and then we run:

git lfs fetch
git lfs checkout

  We can download what we want, and replace the pointer of what we want with a real binary file.

Guess you like

Origin blog.csdn.net/weixin_43590796/article/details/130257331