BFG REPO CLEANER
I am attempting to clean up a Git repository (remove passwords) using BFG repo cleaner:
This is a popular project recommended even officially by GitHub as per:
- https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository
- https://medium.com/@vs28031996/remove-git-history-with-bfg-repo-cleaner-866808826eea
- Remove sensitive files and their commits from Git history
INTENDED USAGE
The intended operation as I understand it is:
- Ensure current Java is installed (Java 8)
- Download current BFG .jar file (all versions here, now 1.14.0), and put in .git folder for project you want to affect.
- Create
passwords.txtfile in same directory with each password you want replaced on a different line. - Ensure the most current commit has the sensitive data (passwords) removed manually.
- Run
java -jar bfg.jar --replace-text passwords.txtand it will clean the older commits.
ERROR
However, this is returning the following error, both from Administrator cmd and from Ubuntu on Windows:
Couldn't find the target main class to run after checking the Java version.
The attribute should be in the Jar manifest and called Main-Class-After-UseNewerJava-Check
MAIN CLASS
The mainClass is defined here it appears in the code, although I don't know Java or how Java projects work (I code C++ and C#):
https://github.com/rtyley/bfg-repo-cleaner/blob/master/bfg/build.sbt
mainClass := Some("use.newer.java.Version8")
packageOptions in (Compile, packageBin) +=
Package.ManifestAttributes( "Main-Class-After-UseNewerJava-Check" -> "com.madgag.git.bfg.cli.Main" )
JAVA VERSIONS
I uninstalled and reinstalled Java 8 in Windows and get from cmd java -version:
java version "1.8.0_401"
Java(TM) SE Runtime Environment (build 1.8.0_401-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.401-b10, mixed mode)
From Ubuntu on Windows I get:
openjdk version "11.0.21" 2023-10-17
OpenJDK Runtime Environment (build 11.0.21+9-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.21+9-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)
Both of these give the same error, even just from java -jar bfg.jar with no other commands.
COMPUTER SPECIFIC ISSUE
I tested on another Windows system, and this does not provide the same error from java -jar bfg.jar (it provides the help information).
So this is clearly a single computer system related issue, although I am not sure what.
Is there any probably reason one Windows computer would provide the error above and another would run it smoothly?
Thanks for any ideas.
It appears to run further than that on my machine (MacBook, OpenJDK 18)
Note, the error message you see may have been triggered later than this . You should be able to replicate this on your system.