git 上傳了一個非常大的檔案,刪除檔案

NO IMAGE

50Mb push 警告

remote: warning: Large files detected.

# remote: warning: File big_file is 55.00 MB; this is larger than GitHub’s recommended maximum file size of 50 MB

100Mb push 限制 

remote: warning: Large files detected.
# remote: error: File giant_file is 123.00 MB; this exceeds GitHub’s file size limit of 100 MB

解決方案如下:

1、需要在伺服器上用git filter-branch --tree-filter 'rm -f 檔名' HEAD把檔案徹底從庫中刪除

    如: git filter-branch –tree-filter ‘rm -f app.rar’ HEAD

2、移除大檔案,注意備份

$git rm –cached giant_file
# Stage our giant file for removal, but leave it on disk

$git commit –amend -CHEAD
# Amend the previous commit with your change
# Simply making a new commit won’t work, as you need
# to remove the file from the unpushed history as well

$git push
# Push our rewritten, smaller commit