Error: Unable to access jarfile bfg.jar - BFG

前端 未结 2 1649
说谎
说谎 2021-02-19 07:47

So I have mistakenly committed my secrets.yml in previous commits (yikes!!) and I want to clean my git commit history of it. It seems the fasted simplest way is to use BFG. I ha

2条回答
  •  既然无缘
    2021-02-19 08:17

    2015: From the documentation, it should be:

    java -jar bfg.jar  yourrepo
    

    Try and use the full path of the jar if you have an error like "Unable to access jarfile bfg.jar": /home/user/path/to/bfg.jar.

    If the jars are configured to be run with java, then /usr/local/bin/bfg would be the path of the symlink referencing the right bfg jar.

    The alternative is described in "Remove sensitive data"

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

    Or (update Nov. 2017), as commented by JeremyDouglass,

    If you download the latest (e.g. from 1.12.16, the bfg-1.12.6.jar) and you only want to use standard commands in a local staging directory only (no path, no symlink), then you can simply rename the jar:

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

    2019-2020: more recently, you would now use You should use git filter-repo (that I mentioned here).

    Install it first. (python3 -m pip install --user git-filter-repo)

    Then, using a path-based filter:

    git filter-repo --path secrets.yml --invert-paths HEAD
    

    HEAD means it will change only your current branch commits.
    Remove HEAD and it will go over all your commits in all your branches.

提交回复
热议问题