1. 按
- 在GitHub上的仓库里只能上传100M以下的文件,如果项目中的某个文件超过了100M,则需要把该文件先用Git Large File Storage追踪(标记)一下,然后再次提交即可。
- 官方主页:https://git-lfs.github.com/
2. 安装
先安装好Git,然后用Git安装lfs
git lfs install
操作步骤
- 用鼠标右键点击左下角的Windows图标,然后点击Windows PowerShell(管理员)
- 运行
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