所以我在之前的提交中错误地提交了我的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,运行时我应该在我的镜像应用程序目录中?还是从应用程序外部运行它?
答案 0 :(得分:3)
java -jar bfg.jar <options> yourrepo
如果您遇到类似&#34; Unable to access jarfile bfg.jar
&#34;:/home/user/path/to/bfg.jar
的错误,请尝试使用jar的完整路径。
If the jars are configured to be run with java,然后/usr/local/bin/bfg
将成为引用右bfg jar的符号链接的路径。
&#34; Remove sensitive data&#34;
中描述了替代方案git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch Rakefile' \
--prune-empty --tag-name-filter cat -- --all
或(2017年11月更新),commented,JeremyDouglass,
如果你download the latest(例如来自1.12.16,
bfg-1.12.6.jar
)并且你只想在本地登台目录中使用标准命令(没有路径,没有符号链接),那么你可以简单地重命名jar:
mv bfg-1.12.16.jar bfg.jar
java -jar bfg.jar --delete-files bad.txt repo.git
答案 1 :(得分:0)
一旦安装了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
答案 2 :(得分:0)
对我来说,bfg jar 的名称中有 version (bfg-1.14.0.jar)。我将 jar 重命名为 bfg.jar 并继续执行该命令并且它起作用了。我知道,愚蠢的错误。但是嘿!