2011-08-26 89 views
7

我不小心將數據庫轉儲(超過1 GB)添加到我的回購庫中,推送它並在幾天後注意到。我使用git filter-branch刪除文件,過期reflog並運行git gc來修剪未使用的對象,但數據庫轉儲blob仍處於回購狀態。我使用了Which commit has this blob?,但確實找到了任何提及blob的提交。我怎樣才能刪除這個或如何找出它在git gc期間沒有被刪除的原因?如何從git repo中刪除blob

+1

請問http://stackoverflow.com/questions/2116778/reduce-git -repository-size/2116892#2116892幫忙嗎?或http://stackoverflow.com/questions/1029969/why-is-my-git-repository-so-big? – VonC

回答

13

運行git gc時,你準確調用了哪個命令?

注混帳GC的手冊頁:

可選配置變量gc.pruneExpire控制未引用的鬆散物多大是不得不被修剪之前。默認值爲「2周前」

所以,如果你的斑點是年齡超過14天,你必須調用

git gc --prune=<date> (for date you also can insert now) 
+0

謝謝,我沒有注意到pruneExpire選項,並沒有意識到git一段時間內保留未被提及的對象。以前,我的確運行過git gc --prune --aggressive。現在,我在git gc --prune之前運行了git reflog --all --expire =,並刪除了blob。 –

0

難道你不能只做rm .git/objects/path/to/blob

我不知道爲什麼git-gc沒有刪除它。

+10

當投票時,每個人都可以解釋爲什麼。它可以幫助每個人在某個主題上閱讀,從而瞭解爲什麼某些東西不太理想或者只是錯誤。 :) –

相關問題