首页 > 解决方案 > BFG ERROR: BFG aborting: No refs to update - nodirty commits found

问题描述

我的 GitHub 存储库中有一个文件,我想删除/重写与该文件相关的所有历史记录。所以我已经将所有与提交相关的提交保存在一个文件中。尝试使用BFG方法。因为我的要求是在不接触代码的情况下重写 git-history。

当我尝试通过此命令使用 BFG 时出现此错误

-bi, --strip-blobs-with-ids <blob-ids-file>

bfg --strip-blobs-with-ids blobs.txt.  user/dam.git --no-blob-protection

Protected commits
-----------------

You're not protecting any commits, which means the BFG will modify the contents of even *current* commits.

This isn't recommended - ideally, if your current commits are dirty, you should fix up your working copy and commit that, check that your build still works, and only then run the BFG to clean up your history.

Cleaning
--------

Found 2289 commits
Cleaning commits:       100% (2289/2289)
Cleaning commits completed in 503 ms.

BFG aborting: No refs to update - no dirty commits found??

标签: gitgithubbfg-repo-cleaner

解决方案


出现该错误是因为 BFG 找不到 blobs.txt 文件中提到的 Git 对象 ID。

请确保您使用的对象 ID 不是 blob 内容的 SHA-1 哈希值。您可以使用以下命令获取任何文件的对象 ID -

$ git hash-object README.md
a63b49c2e93788cd71c81015818307c7b70963bf

BFG 还提供了不同的命令来从历史记录中删除文件/文件夹。

$ bfg --delete-files id_{dsa,rsa}  my-repo.git

$ bfg --delete-folders {FolderName1, FolderName2}  --no-blob-protection  my-repo.git

推荐阅读