git - 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??
解决方案
出现该错误是因为 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
推荐阅读
- docker - 我们如何在 django .env 文件中传递动态端口名称
- selenium - 无法通过 jenkins 在 Microsoft 团队中查看测试自动化结果
- python - 在 Python3 中统一替换 Python2 的 StringIO 是什么?
- java - 图像未填满正方形
- android - 如何让一个方法等到它的改造方法在返回之前得到它的响应?
- c# - 如何将 JToken 转换为字符串 []?
- tensorflow - 在 tensorflow 2.0 中,如何计算输入变量的损失梯度?
- c# - 新 csproj 格式引用旧 csproj 是否有任何问题,反之亦然
- excel - 删除excel中N号后的所有行
- typescript - 如何使用@ts-ignore 忽略打字稿错误?