rtyley / bfg-repo-cleaner

Removes large or troublesome blobs like git-filter-branch does, but faster. And written in Scala
https://rtyley.github.io/bfg-repo-cleaner/
GNU General Public License v3.0
10.86k stars 535 forks source link

Cannot remove jar files from repo #392

Open scottpig opened 4 years ago

scottpig commented 4 years ago

I've used bfg to successfully remove several files and folders from my repo, but it seems to have a blind spot for jar files.

I can see that there are deleted jar files in the repo when I run this command:

git log --diff-filter=D --summary | grep delete > ../deleted.txt

But when I attempt to remove them with this,

java -jar bfg-1.13.0.jar --delete-files *.jar MyBigRepo.git

It can't find anything to remove:

$ java -jar bfg-1.13.0.jar --delete-files jar MyBigRepo.git

Using repo : MyBigRepo.git

Found 1893 objects to protect
Found 12 commit-pointing refs : HEAD, refs/heads{ snip }...

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

These are your protected commits, and so their contents will NOT be altered:

 * commit 017a5f35 (protected by 'HEAD')

Cleaning
--------

Found 5551 commits
Cleaning commits:       100% (5551/5551)
Cleaning commits completed in 14,175 ms.

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

The command works as expected for other file types. It seems that only jar files can't be cleaned. Am I missing something?

ymartin59 commented 4 years ago

It may be that these jar files are no longer attached to references. Have you run gc to expire and prune blobs in repository first: git -c gc.reflogExpireUnreachable=0 -c gc.pruneExpire=now gc

brlin-tw commented 3 years ago

java -jar bfg-1.13.0.jar --delete-files *.jar MyBigRepo.git

A major problem with this command is that in sh/bash the *.jar expression expands to bfg-1.13.0.jar and other *.jar files' filenames in your working directory due to the filename expansion feature if you don't quote it up.

It is actually running java -jar bfg-1.13.0.jar --delete-files bfg-1.13.0.jar _foo_.jar _bar_.jar MyBigRepo.git

Please check if this causes the issue.

Zhabha commented 3 years ago

I've actually run into the same problem, I'm not able to remove jar files regardless if I use the quotes or no java -jar bfg-1.13.2.jar --delete-files *.jar myRepo java -jar bfg-1.13.2.jar --delete-files '*.jar' myRepo Both commands end up reporting there's nothing to remove.

I've also tried to make the jar files be deleted along with other file types like this java -jar bfg-1.13.2.jar --delete-files '*.{exe,dll,jar}' myRepo The result in this case is the same, nothing at all is deleted. But if I remove the jar from the extensions, both exe and dll files are removed.

The only workaround I've been able to find is to remove the jar files alphabetically, executing the command for each starting letter, in which case the cleaning is done as expected. Example: java -jar bfg-1.13.2.jar --delete-files a*.jar myRepo

ranandverint commented 2 years ago

Same problem faced by me too. For other file types, this works fine, but ".jar" & ".war" don't seem to work at all.

@rtyley - Do you have any solutions for this? or is this a bug that is supposed to be fixed?