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