由於Github 有單一的文檔大小限制,如果超過了100MB就會顯示上傳失敗出現下面的情況。
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: da815a6d6f452ecffe5fa628c59519a8
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File crawlTPL/data/reusageMapping.csv is 332.44 MB; this exceeds GitHub's file size limit of 100.00 MB
在這裏顯示了我的文檔 reusageMapping.csv is 332.44 MB 是332,44MB已經超過了他的限制。這個時候我們需要使用git filter-branch 將這個檔案從我們的 git repository裏面刪除。
- 首先我們需要跳轉到我們的git 根目錄下
cd YOUR-REPOSITORY
- 將這個文檔從我們的git 記錄中刪除,我已開始直接先用 rm 刪除的,然後在 git add -A 和 commit了一下。之後在用的這個命令
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA" \
--prune-empty --tag-name-filter cat -- --all
PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA 這個就是我們過大的文檔
對應我的問題就是如下所示操作的:
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch ./crawlTPL/data/reusageMapping.csv" --prune-empty --tag-name-filter cat -- --all
如下圖所示,操作
3. 最後,我們只需要將最新的git push 回 GitHub 就可以了。