File lớn trong git history không thể xóa bằng git rm đơn giản — vẫn tồn tại trong object store.
Identify: git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -10 liệt kê blobs lớn nhất (đối chiếu tên file qua git rev-list --objects --all).
Remove với git filter-repo (khuyến nghị):
pip install git-filter-repo
git filter-repo --path large-video.mp4 --invert-paths
git filter-repo --strip-blobs-bigger-than 10M # hoặc xóa mọi blobs >10MB
git push --force --all && git push --force --tagsBFG Repo Cleaner là lựa chọn nhanh hơn cho history rất dài (bfg --strip-blobs-bigger-than 50M, sau đó git reflog expire --expire=now --all && git gc --prune=now).
Coordinate với team: thông báo "history rewritten — re-clone", đừng pull — pull không clean được local repo cũ.
Phòng tránh lần sau:
- Git LFS cho binary assets (design files, videos, binaries)
- Custom pre-commit hook để check file size (ví dụ: find . -size +10M | grep -v .git và exit 1 nếu tìm thấy) — git config hooks.maxfilesize KHÔNG phải git config thực; phải viết script thủ công
- .gitignore cho build outputs, node_modules, log files.