【问题标题】:Removing history using BFG Cleaner not working使用 BFG Cleaner 删除历史记录不起作用
【发布时间】:2019-06-24 15:07:54
【问题描述】:

使用 BFG 删除已删除文件夹的历史记录

我正在使用 BFG 从 repo 中完全删除已删除文件夹的历史记录

git rev-list --all --objects -- path/to/the/directory/to/delete | git cat-file --batch-check='%(objectname) %(objecttype) %(rest)' | grep -Pe '^\w+ blob' |剪切 -d' ' -f1 > ./to-delete.txt java -jar bfg.jar --no-blob-protection --strip-blob-with-ids ./to-delete.txt

我得到了对象 ID 列表,但是当我使用以下命令将对象 ID 传递给 bfg 时,它会抛出错误

java -jar bfg.jar --no-blob-protection --strip-blob-with-ids ./to-delete.txt

错误: java.exe:错误:选项 --strip-blobs-with-ids 在给定“RCC.txt”时失败。 MainException:类 org.eclipse.jgit.errors.InvalidObjectIdException(**无效 id:**??e 4 c 8 e 1 b b 1 7 8 2 4 8 7 1 9 2 9 9 b 0 1 5 b 1 5 0 8 3 9 2 7 b d e f f 5 b) 在 G:\Dev_Migration_Scripts\RepoCleaner_New.ps1:29 char:35

【问题讨论】:

    标签: bfg-repo-cleaner


    【解决方案1】:

    试试bfg -B 1 --no-blob-protection

    阅读BFG usage instructionsthis guide

    git rm -r --cached . 从 Git 中删除所有缓存。这总能解决我的问题。

    git reset --hard 只留下提交的文件,git clean -d -x -f 删除未跟踪的文件,包括目录 (-d) 和 git 忽略的文件 (-x)。

    了解git rmheregit cleanheregit resethere

    我知道最后一个不是来自 BFG,但他们可能会帮助你。

    【讨论】:

    • 谢谢。我已经按照上面的链接,但它没有工作。我需要删除已删除文件夹(有子文件夹)的历史记录
    【解决方案2】:

    我使用了与您相同的技术,并且遇到了 BFG 为使用 git rev-listgit cat-file 生成的 blob 散列引发 InvalidObjectIdException 的相同问题

    问题在于文本文件的编码,如果您查看无效的 id **??e 4 c 8 e 1 b b 1 7 8 2 4 8 7 1 9 2 9 9 b 0 1 5 b 1 5 0 8 3 9 2 7 b d e f f 5 b,您会看到多余的字符,如果哈希正确但未找到,则它只是 e4c8e1bb178248719299b015b15083927bdeff5b

    在我的例子中,我使用 Notepad++ 过滤我想要删除的 blob,并且由于某种原因,编码切换到 UCS-2 LE BOM。切换回 UTF-8 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-05
      • 1970-01-01
      • 2012-08-30
      • 2011-02-10
      • 1970-01-01
      相关资源
      最近更新 更多