我想清除所有Blob和以前删除的文件的历史记录(即HEAD中不再存在),我目前正在运行以下命令,但是BFG似乎删除了所有Blob,包括HEAD中存在的那些Blob:
git log # Returns 1050 commits
git commit -a -m "Clean the old history and blobs with BFG"
java -jar bfg.jar --delete-files '*' # Delete all files not in HEAD
git log # Still returns 1050 commits, all empty
git diff 5458b2^ 5458b2 # Returns 0 change, while it concerns a protected file
BFG实际上考虑了HEAD中受保护的文件,例如gitignore:
Protected commits
-----------------
These are your protected commits, and so their contents will NOT be altered:
* commit 22a1ebd3 (protected by 'HEAD') - contains 1451 dirty files :
- .gitignore (813 B)
- ...
但是无论如何,它们都会被删除,而应该受到保护:
Deleted files
-------------
Filename Git id
----------------------------------------
.gitignore | 091217cf (672 B), 17e3d7c5 (227 B)...
我最终使用该脚本从过时的已删除文件中清理存储库。它结合了分支重写和垃圾回收器调用的几个步骤,以清理当前存储库。
我设法在4MB的新存储库中压缩了700MB的大型仓库。与往常一样,在运行这种脚本之前,请复制存储库,这可能会导致数据丢失!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句