[英]How do I clean all git history and blobs of files not currently present in HEAD with BFG
I want to clean all blobs and history of files that have been previously deleted (ie no longer present in HEAD), I am currently running these commands, but BFG seems deleting all blobs, including those present in HEAD: 我想清除所有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 actually took into account the protected files in HEAD, like gitignore for example: 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)
- ...
But they are removed anyway, while they are supposed to be protected: 但是无论如何,它们都会被删除,而应该受到保护:
Deleted files
-------------
Filename Git id
----------------------------------------
.gitignore | 091217cf (672 B), 17e3d7c5 (227 B)...
I am finally using that script to clean up the repository from obsolete deleted files. 我最终使用该脚本从过时的已删除文件中清理存储库。 It combines several steps of branch rewritings and garbage collector call to clean the current repository.
它结合了分支重写和垃圾回收器调用的几个步骤,以清理当前存储库。
I managed to compress a 700MB heavy repo in a 4MB fresh repository. 我设法在4MB的新存储库中压缩了700MB的大型仓库。 As usual, duplicate your repository before running this kind of script, it might result in some lost of data!
与往常一样,在运行这种脚本之前,请复制存储库,这可能会导致数据丢失!
Maybe you can try the following command to delete all unreachable objects. 也许您可以尝试使用以下命令删除所有无法访问的对象。
git prune
git prune
or 要么
git gc
git gc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.