鏡像下載、域名決議、時間同步請點擊 阿里云開源鏡像站
一、Git LFS
Git Large File Storage (LFS) 使用 Git 內部的文本指標替換音頻樣本、視頻、資料集和圖形等大檔案,同時將檔案內容存盤在 GitHub.com 或 GitHub Enterprise 等遠程服務器上,通常用來管理大的二進制檔案,
Git LFS 通過將倉庫中的大檔案替換為微小的指標(pointer) 檔案來做到這一點,在正常使用期間,你將永遠不會看到這些指標檔案,因為它們是由 Git LFS 自動處理的,
關于 LFS 的指標檔案:
LFS 的指標檔案是一個文本檔案,存盤在 Git 倉庫中,對應大檔案的內容存盤在 LFS 服務器里,而不是 Git 倉庫中,下面為一個圖片 LFS 檔案的指標檔案內容:
version https://git-lfs.github.com/spec/v1
oid sha256:5b62e134d2478ae0bbded57f6be8f048d8d916cb876f0656a8a6d1363716d999
size 285
指標檔案很小,小于 1KB,其格式為 key-value 格式,第一行為指標檔案規范 URL,第二行為檔案的物件 id,也即 LFS 檔案的存盤物件檔案名,可以在.git/lfs/objects 目錄中找到該檔案的存盤物件,第三行為檔案的實際大小(單位為位元組),所有 LFS 指標檔案都是這種格式,
二、Git LFS的安裝
(1)
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash

ubuntun默認的軟體倉庫位置在/etc/apt/sources.list檔案中,但在/etc/apt/sources.list.d/目錄也有一些軟體源(第三方軟體的源,可以分別存放不同的第三源地址),我們的git-lfs就是在這個目錄下:
在/etc/apt/sources.list.d/目錄下多了github_git-lfs.list檔案:


(2)
sudo apt-get install git-lfs

git lfs env
--Display the Git LFS environment.

Error: Failed to call git rev-parse --git-dir: exit status 128
(3)
git init //解決上述問題:Error: Failed to call git rev-parse --git-dir: exit status 128
git lfs install
--Install Git LFS configuration.
執行git init 會生成 /lfs/objects/、/lfs/tmp/目錄,


運行 git lfs install 一次,為你的系統初始化后,當你克隆包含 Git LFS 內容的倉庫時,Git LFS 將自動進行自我引導啟用,
git lfs env

三、使用Git LFS
(1)
git clone 命令來克隆 Git LFS 倉庫,并且將自動為你下載完成檢出程序所需的所有 Git LFS 檔案:
使用下面兩個都可以:
git clone
git lfs clone
(2)
git pull 命令拉取 Git LFS 倉庫,拉取完成后,所有需要的 Git LFS 檔案都會作為自動檢出程序的一部分而被下載:
git pull
git lfs pull
(3)
git push提交時:
當向倉庫中添加新的大檔案型別時,你需要通過使用 git lfs track 命令指定一個模式來告訴 Git LFS 對其進行跟蹤:
這是告訴git lfs哪些檔案要被git lfs管理,這步非常重要,
$ git lfs track "*.ogg"
Tracking *.ogg
--View or add Git LFS paths to Git attributes.
比如:

然后就可以正常的使用git提交lfs檔案了:
gitattributes 是一種 Git 機制,用于將特殊行為系結到某些檔案模式,Git LFS 自動創建或更新.gitattributes 檔案,以將跟蹤的檔案模式系結到 Git LFS 過濾器,但是,你需要將對.gitattributes 檔案的任何更改自己提交到倉庫:
git lfs track "*.ogg"
git add .
//git add .gitattributes
git commmit -m "log"
git push
(4)
通過呼叫不帶引數的 git lfs track 命令來顯示 Git LFS 當前正在跟蹤的所有模式的串列(以及它們在其中定義的.gitattributes 檔案):
git lfs track

總結
參考man手冊的使用:
git lfs track "*.iso"
git add .gitattributes
git add file.iso
git commit -m "Add disk image"
git push
EXAMPLES
To get started with Git LFS, the following commands can be used.
1. Setup Git LFS on your system. You only have to do this once per
repository per machine:
git lfs install
2. Choose the type of files you want to track, for examples all ISO
images, with git-lfs-track(1):
git lfs track "*.iso"
3. The above stores this information in gitattributes(5) files, so
that file need to be added to the repository:
git add .gitattributes
4. Commit, push and work with the files normally:
git add file.iso
git commit -m "Add disk image"
git push
原文鏈接:https://blog.csdn.net/weixin_45030965/article/details/125678454
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/500230.html
標籤:Linux
上一篇:Linux串口編程
