請參考官方網站 維護及資料復原 ...
注意 請先將資料備份 若改壞恕不負責
使用 "C:\Program Files\Git\git-bash.exe", 看一下Git 控管中資料到底有多少,
先用 git 整理一下資料,
$ git gc
Counting objects: 118, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (103/103), done.
Writing objects: 100% (118/118), done.
Total 118 (delta 74), reused 0 (delta 0)
看看資料大小:
$ git count-objects -v
count: 0
size: 0 <===== 尚未整裡的資料大小
in-pack: 118
packs: 1
size-pack: 88824 <===== 整理後的資料大小 (88MB)
prune-packable: 0
garbage: 0
size-garbage: 0
先看看我們有什麼大的檔案 在 git 歷史裡
$ git verify-pack -v .git/objects/pack/pack-f281f7156b17e6bd09a5997530c06f73f00d35d9 | sort -k 3 -n | tail -3
41695866016a1b15c0afca6f245ead1688927a78 blob 48375598 17882652 73069419 1 431afce4d21aae4f7456423d57e7aa41e5270572
431afce4d21aae4f7456423d57e7aa41e5270572 blob 107386372 18624491 54444035
98cfa13fbe22f508b65b58772b18d0888f7a02e8 blob 107386372 18662533 27542
偷懶的做法:
$ git verify-pack -v .git/objects/pack/* | sort -k 3 -n | tail -3
431afce4d21aae4f7456423d57e7aa41e5270572 blob 107386372 18624491 54444035
98cfa13fbe22f508b65b58772b18d0888f7a02e8 blob 107386372 18662533 27542 <== 會有重複的
98cfa13fbe22f508b65b58772b18d0888f7a02e8 blob 107386372 18662533 27542
檔案名稱反查
$ git rev-list --objects --all | grep 98cfa13f
98cfa13fbe22f508b65b58772b18d0888f7a02e8 wx_pch.h.gch/Debug_wx_pch_h_gch
知道名稱後,就可以把他從 Git 控管的歷史中移除掉
$ git filter-branch --index-filter 'git rm --cached --ignore-unmatch wx_pch.h.gch/Debug_wx_pch_h_gch'
Rewrite a9d6e52a7bbfe36b82aa1b84aaf2042ff6942210 (1/7) (0 seconds passed, remaining 0 predicted) rm 'wx_pch.h.gch/Debug_wx_pch_h_gch'
Rewrite 5d5eba75d45a1da9728be2536c72db25831fb4d3 (2/7) (1 seconds passed, remaining 2 predicted) rm 'wx_pch.h.gch/Debug_wx_pch_h_gch'
Rewrite 7dd375e3e9f5a92c8af45ea9e418a9ba9f4f6258 (2/7) (1 seconds passed, remaining 2 predicted) rm 'wx_pch.h.gch/Debug_wx_pch_h_gch'
Rewrite a46b60616757186fb94f2a3d81f526b3c6e4db19 (2/7) (1 seconds passed, remaining 2 predicted) rm 'wx_pch.h.gch/Debug_wx_pch_h_gch'
Rewrite c89c8050190e6c9c4a7054843a210ec545848f1d (5/7) (2 seconds passed, remainRewrite 22fd295101421c6d805bd076d359e94938da731f (5/7) (2 seconds passed, remainRewrite 342f4d3624e78b7528eeb4ebbd1ccafd033162e6 (5/7) (2 seconds passed, remaining 0 predicted)
Ref 'refs/heads/master' was rewritten
再讓 Git 整理一下資料
Rewrite 5d5eba75d45a1da9728be2536c72db25831fb4d3 (2/7) (1 seconds passed, remaining 2 predicted) rm 'wx_pch.h.gch/Debug_wx_pch_h_gch'
Rewrite 7dd375e3e9f5a92c8af45ea9e418a9ba9f4f6258 (2/7) (1 seconds passed, remaining 2 predicted) rm 'wx_pch.h.gch/Debug_wx_pch_h_gch'
Rewrite a46b60616757186fb94f2a3d81f526b3c6e4db19 (2/7) (1 seconds passed, remaining 2 predicted) rm 'wx_pch.h.gch/Debug_wx_pch_h_gch'
Rewrite c89c8050190e6c9c4a7054843a210ec545848f1d (5/7) (2 seconds passed, remainRewrite 22fd295101421c6d805bd076d359e94938da731f (5/7) (2 seconds passed, remainRewrite 342f4d3624e78b7528eeb4ebbd1ccafd033162e6 (5/7) (2 seconds passed, remaining 0 predicted)
Ref 'refs/heads/master' was rewritten
再讓 Git 整理一下資料
$ rm -Rf .git/refs/original
$ rm -Rf .git/logs/
$ git gc
Counting objects: 64, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (64/64), done.
Total 64 (delta 34), reused 53 (delta 33)
$ git prune --expire=now
看看整理過後的資料大小:
$ git count-objects -v
$ git count-objects -v
count: 0
size: 0
in-pack: 64
packs: 1
size-pack: 39
prune-packable: 0
garbage: 0
size-garbage: 0
縮小好多 就等待檢查資料有沒有被改壞.....
沒有留言:
張貼留言
手機選擇帳號後,按下發布 要再點選一次發布哦