Troubleshooting BFG Repo-Cleaner

Last updated on:July 17, 2022

(Banner: Unsplash)

Cleaning file history with BFG Repo-Cleaner

昨天整理文件时有东西传错了,想把GitHub History一起清理掉。

先找到官网这篇

里面提到两种方法:

  • Using the BFG(快速操作)
  • Using git filter-repo(常规办法)

然而我不管跑哪个,都出现了下面的报错:

1
2
The operation couldn’t be completed. Unable to locate a Java Runtime xxx
Please visit http://www.java.com for information on installing Java.

什么难道我没有Java……

于是开始用brew装Java,但总是出现这条

1
Error: Failure while executing; 'git clone [https://github.com/Homebrew/homebrew-cask](https://github.com/Homebrew/homebrew-cask)/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask' exited with 128.

搜着搜着开始尝试

替换homebrew源

1
2
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

替换homebrew-core源

1
2
3
4
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

$ brew update

接着跑了下面一堆

1
$ brew doctor
1
$ brew cleanup
1
$ brew upgrade

看它似乎活过来了,于是缓缓尝试

1
$ brew install java

———————— 200 years later ————————

1
2
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

检查是否安装成功

1
2
3
4
5
$ java -version

openjdk version "18.0.1.1" 2022-04-22
OpenJDK Runtime Environment Homebrew (build 18.0.1.1+0)
OpenJDK 64-Bit Server VM Homebrew (build 18.0.1.1+0, mixed mode, sharing)

成功之后就可以用 BFG Repo-Cleaner 了,中文看这两篇:

下载之后记得匹配bfg.jar的命名和位置……

如果要用 bfg 作为 java -jar bfg.jar 的 alias,需要先

1
$ alias bfg="java -jar bfg.jar"

如果 git push 之后出现

1
Error: failed to push some refs to xxx.git

搜到古早的这个issue

1
$ git push origin master --force

然后似乎就没有了😴

2022/07/01