我在 Bitbucket 中有一個使用了約 160MB 的存盤庫,我洗掉了所有分支。回購完全清楚,它繼續說我使用了 160 MB。
圖片
我怎樣才能真正洗掉我的倉庫中的所有檔案。我不想創建一個新的倉庫。
作為補充。如果我添加一些檔案,例如“file.mp3”到 repo,然后我洗掉它,它會增加 repo 大小,我不能再次減小它。我嘗試了一些類似Atlassian Help的帖子。
最好的,
編輯:我正在嘗試使用 BFG。當我制作“bfg --strip-blobs-bigger-than 1M”時,我得到:
Scanning packfile for large blobs: 115
Scanning packfile for large blobs completed in 16 ms.
Found 6 blob ids for large blobs - biggest=47522424 smallest=1515614
Total size (unpacked)=102234236
Found 2 objects to protect
Found 4 commit-pointing refs : HEAD, refs/heads/11.0.0-7, refs/heads/master, refs/notes/master
Protected commits
-----------------
These are your protected commits, and so their contents will NOT be altered:
* commit 57632224 (protected by 'HEAD')
Cleaning
--------
Found 3 commits
Cleaning commits: 100% (3/3)
Cleaning commits completed in 166 ms.
Updating 1 Ref
--------------
Ref Before After
-----------------------------------------
refs/heads/11.0.0-7 | b333507a | 37b0f5cb
Updating references: 100% (1/1)
...Ref update completed in 16 ms.
Commit Tree-Dirt History
------------------------
Earliest Latest
| |
. D .
D = dirty commits (file tree fixed)
m = modified commits (commit message or parents changed)
. = clean commits (no changes to file tree)
Before After
-------------------------------------------
First modified commit | b333507a | 37b0f5cb
Last dirty commit | b333507a | 37b0f5cb
Deleted files
-------------
Filename Git id
-----------------------------------------------------------
Image.png | 6481d63a (3,3 MB)
Sfile3.rpm | e8b6f2b8 (29,4 MB)
UserManual.pdf | 77c29187 (16,2 MB)
c.res | 92392c06 (1,4 MB)
xxxx.png | 6481d63a (3,3 MB)
file1 | f24d869b (45,3 MB)
file2 | 4e62ab09 (1,9 MB)
In total, 9 object ids were changed.
uj5u.com熱心網友回復:
問題是 git 永久存盤哈希,因此您必須更加努力地洗掉內容。通過洗掉分支,您實際上只是洗掉了對存盤在存盤庫中的補丁的參考。
我建議您嘗試使用bfg。它非常快速且易于使用。
git clone --mirror git://example.com/some-big-repo.git
java -jar bfg.jar --strip-blobs-bigger-than 100M some-big-repo.git
cd some-big-repo.git
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push --force
這些設定需要根據您的需要進行更改,但這實際上會重寫存盤庫中 blob 的內容。
確認
為了驗證這些步驟,我執行了以下操作:
mkdir bfg-test
cd bfg-test
echo "Test bfg cleanup in bitbucket." > README.md
git init
git remote add origin [email protected]:theherk/bfg-test.git
git add README.md
git commit -m "Initial commit."
git push origin main
# size in bitbucket.org: 57.94 KB
dd if=/dev/urandom bs=1048577 count=1 | base64 > garbage
git add garbage
git checkout -b garbage-branch
git commit -m "Add garbage file."
git push origin garbage-branch
# size in bitbucket.org: 1.12 MB
git checkout main
git branch -D garbage-branch
git push origin -d garbage-branch
# size in bitbucket.org: 1.12 MB
cd ..
git clone --mirror [email protected]:theherk/bfg-test.git
java -jar ~/bin/bfg.jar --strip-blobs-bigger-than 1K bfg-test.git
在這一點上,我沒有發現大的斑點。如果它在那里,它就會被剝奪。所以我檢查了回購鏡像的大小。88 KB;而 bitbucket.org 報告的 1.12 MB。事實證明,bitbucket 確實修剪了檔案,并且存盤庫實際上更小,它們的界面只是謊言并報告使用情況,包括將在以后清理的懸空檔案。
最重要的是,如果您的克隆較小,則不要相信存盤庫設定中的資訊。
uj5u.com熱心網友回復:
將物件添加到物件資料庫后,如果物件沒有被當前分支/標簽之類的東西指向,它將至少在那里停留一段時間。即使物件沒有被分支/標簽指向,它仍然可以被 reflog 持有一段時間,這可能需要一點時間來允許清除修訂。Git 每隔一段時間就會進行一次垃圾收集……你可以強制使用git gc. 檢查它的選項并玩得開心。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/483506.html
