如何在git歷史中查找/識別大型提交?我有一個300 MB的git repo。我目前檢出的文件重2 MB,git repo重298 MB。這基本上是一個僅限代碼的回購,重量不應超過幾MB。最有可能的是,有人在某個時候偶然犯了一些重文件(視頻,巨大的圖像等),然后將它們刪除......但不是從git中刪除,所以我們有無用大文件的歷史。如何在git歷史記錄中追蹤大文件?有400多個提交,所以一個接一個將是耗時的。
3 回答

阿晨1998
TA貢獻2037條經驗 獲得超6個贊
試試git ls-files | xargs du -hs --threshold=1M
。
我們在CI管道中使用下面的命令,如果它在git repo中找到任何大文件,它就會停止:
test $(git ls-files | xargs du -hs --threshold=1M 2>/dev/null | tee /dev/stderr | wc -l) -gt 0 && { echo; echo "Aborting due to big files in the git repository."; exit 1; } || true
- 3 回答
- 0 關注
- 714 瀏覽
添加回答
舉報
0/150
提交
取消