2015-09-06 80 views
11

所以我錯誤地提交了我的secrets.yml在以前的提交(yikes !!),我想清理我的git提交歷史記錄。看起來禁食最簡單的方法是使用BFG。我已經下載的jar文件,並安裝了Java的需要,我已經創建了回購的一面鏡子 - 但是當我運行命令按照文檔:錯誤:無法訪問jarfile bfg.jar - BFG

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,並且當我運行鏡像應用程序的目錄時,我應該在之內?還是從應用程序的外部運行它?

回答

2

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

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 
+0

謝謝VonC,我終於描述剛剛放棄它,並根據git文檔使用'git filter-branch'完成它,我應該嘗試完整路徑,a如果他們在文檔中包含一些錯誤,它會很棒,但這就是生活。無論如何我都完成了工作 - 但我會在下次嘗試使用bfg時嘗試完整路徑!再次感謝;) – HolyMoly

+2

@HolyMoly很高興你做到了。我編輯了包含'git filter-branch'選項的答案。 – VonC

+0

感謝您使用'git filter-branch'信息進行更新 - 我相信這會幫助其他人絆倒這個(他們似乎仍然在這裏找到他們的方式!);) – HolyMoly