TOC

Git LFS

开源中国文章 紧跟 AI 步伐, Gitee 已支持 AI 模型托管 中介绍了 Git LFS 的使用。

结合 git lfs help,记录如下:

  1. 需要先 install 一下,启用 LFS 功能

    $ git lfs install
    Updated Git hooks.
    Git LFS initialized.
    
  2. 追踪大文件

    git lfs trace path/to/largefile
    # 会记录在 .gitattributes 文件中
    # path/to/largefile filter=lfs diff=lfs merge=lfs -text
    
  3. 推送大文件

    # 正常提交
    git add .gitattributes path/to/largefile
    git commit -m "..."
    
    # 推送
    git lfs push --all
    git lfs push --all origin
    
  4. 拉取大文件

    git lfs pull --all
    
    # 指定文件
    git lfs pull -I <filepath>
    
  5. git lfs ls-files 列出大文件