把某個檔案或目錄完整從 git repo 中移除

緣起:某開發者把影片檔 commit 在 repo 裡,即使 git rm 後,因為記錄仍留在 history 中,導致在做 first push 或 clone 時,時間過久。

git filter-branch --tree-filter 'rm -f assets/videos/hero.mp4' HEAD

這樣就會把此 repo 從第一個 commit 開始掃描,逐一清理乾淨,最後再 force push 就可以了。

你可能感兴趣的:(把某個檔案或目錄完整從 git repo 中移除)