Git借助Git Large File Storage上传大文件

1. 按

  • 在GitHub上的仓库里只能上传100M以下的文件,如果项目中的某个文件超过了100M,则需要把该文件先用Git Large File Storage追踪(标记)一下,然后再次提交即可。
  • 官方主页:https://git-lfs.github.com/

2. 安装

先安装好Git,然后用Git安装lfs

git lfs install

操作步骤

  1. 用鼠标右键点击左下角的Windows图标,然后点击Windows PowerShell(管理员)
    在这里插入图片描述
  2. 运行
    git lfs install
    
    在这里插入图片描述

3. 追踪某个大文件

  • 项目的根目录为F:\UnityProjects\AntivirusFC
    在这里插入图片描述
  • 文件所在的目录为F:\UnityProjects\AntivirusFC\Assets\Model\town
    在这里插入图片描述
  • 在文件资源管理器中转到F:\UnityProjects\AntivirusFC\Assets\Model\town,然后同时按Shift键+鼠标键,这时会出现在此处打开Powershell窗口,点击它
    在这里插入图片描述
  • 然后运行
    git lfs track "城镇场景.fbx"
    
    在这里插入图片描述
  • 会看到相应的目录中多出一个.gitattributes文件
    在这里插入图片描述
  • 最后再提交就行了
    在这里插入图片描述

4. 更多使用 Git LFS 跟踪文件的用法

当向仓库中添加新的大文件类型时,你需要通过使用 git lfs track 命令指定一个模式来告诉 Git LFS 对其进行跟踪:

git lfs track "*.ogg"

请注意,"*.ogg"周围的引号很重要。省略它们将导致通配符被 shell 扩展,并将为当前目录中的每个.ogg 文件创建单独的条目:

# probably not what you want
git lfs track *.ogg
Tracking explode.ogg
Tracking music.ogg
Tracking phaser.ogg

Git LFS 支持的模式与.gitignore 支持的模式相同,例如:

# track all .ogg files in any directory
git lfs track "*.ogg"
# track files named music.ogg in any directory
git lfs track "music.ogg"
# track all files in the Assets directory and all subdirectories
git lfs track "Assets/"
# track all files in the Assets directory but *not* subdirectories
git lfs track "Assets/*"
# track all ogg files in Assets/Audio
git lfs track "Assets/Audio/*.ogg"
# track all ogg files in any directory named Music
git lfs track "**/Music/*.ogg"
# track png files containing "xxhdpi" in their name, in any directory
git lfs track "*xxhdpi*.png
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章