错误:无法访问jarfile bfg.jar - BFG

问题描述 投票:12回答:2

所以我在之前的提交中错误地提交了我的secrets.yml(yikes !!),我想清理我的git提交历史。似乎禁食最简单的方法是使用BFG。我已经下载了jar文件并安装了Java是必需的,并且我创建了一个我的repo的镜像 - 但是当我按照文档运行命令时:

java -jar bfg.jar --delete-files secrets.yml my-repo.git

我得到错误Unable to access jarfile bfg.jar

文档非常漂亮,但没有说明我应该做些什么来安装它或让它运行,或链接到我的镜像仓库,我很困惑。我看了一个youtube教程,说我应该使用像这样的命令创建一个符号链接;

ln -s ~/bfg-1.11.6.jar /usr/local/bin/bfg

运行bfg,除了我不确定该命令的第二部分是指(/usr/local/bin/bfg)或它应该指向我的情况,因为这对我来说不起作用。我将jar文件保存在用户根目录中。我需要搬家吗?如何在镜像仓库上运行BFG,运行时我是否应该在镜像应用程序目录中?或者从应用程序外部运行它?

git jar
2个回答
3
投票

From the documentation,它应该是:

java -jar bfg.jar <options> yourrepo

如果您遇到类似“Unable to access jarfile bfg.jar”的错误,请尝试并使用jar的完整路径:/home/user/path/to/bfg.jar

If the jars are configured to be run with java,然后/usr/local/bin/bfg将是引用右bfg jar的符号链接的路径。

另一种描述在“Remove sensitive data”中

git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch Rakefile' \
--prune-empty --tag-name-filter cat -- --all

或者(2017年11月更新),commentedJeremyDouglass

如果你download the latest(例如来自1.12.16bfg-1.12.6.jar)并且你只想在本地登台目录中使用标准命令(没有路径,没有符号链接),那么你可以简单地重命名jar:

mv bfg-1.12.16.jar bfg.jar 
java -jar bfg.jar --delete-files bad.txt repo.git

1
投票

一旦安装了BFG(例如使用brew install BFG),就可以在终端中调用BFG命令。 以下是BFG的命令行帮助:

bfg
bfg 1.13.0
Usage: bfg [options] [<repo>]

  -b, --strip-blobs-bigger-than <size>
                           strip blobs bigger than X (eg '128K', '1M', etc)
  -B, --strip-biggest-blobs NUM
                           strip the top NUM biggest blobs
  -bi, --strip-blobs-with-ids <blob-ids-file>
                           strip blobs with the specified Git object ids
  -D, --delete-files <glob>
                           delete files with the specified names (eg '*.class', '*.{txt,log}' - matches on file name, not path within repo)
  --delete-folders <glob>  delete folders with the specified names (eg '.svn', '*-tmp' - matches on folder name, not path within repo)
  --convert-to-git-lfs <value>
                           extract files with the specified names (eg '*.zip' or '*.mp4') into Git LFS
  -rt, --replace-text <expressions-file>
                           filter content of files, replacing matched text. Match expressions should be listed in the file, one expression per line - by default, each expression is treated as a literal, but 'regex:' & 'glob:' prefixes are supported, with '==>' to specify a replacement string other than the default of '***REMOVED***'.
  -fi, --filter-content-including <glob>
                           do file-content filtering on files that match the specified expression (eg '*.{txt,properties}')
  -fe, --filter-content-excluding <glob>
                           don't do file-content filtering on files that match the specified expression (eg '*.{xml,pdf}')
  -fs, --filter-content-size-threshold <size>
                           only do file-content filtering on files smaller than <size> (default is 1048576 bytes)
  -p, --protect-blobs-from <refs>
                           protect blobs that appear in the most recent versions of the specified refs (default is 'HEAD')
  --no-blob-protection     allow the BFG to modify even your *latest* commit. Not recommended: you should have already ensured your latest commit is clean.
  --private                treat this repo-rewrite as removing private data (for example: omit old commit ids from commit messages)
  --massive-non-file-objects-sized-up-to <size>
                           increase memory usage to handle over-size Commits, Tags, and Trees that are up to X in size (eg '10M')
  <repo>                   file path for Git repository to clean
© www.soinside.com 2019 - 2024. All rights reserved.