[英]Renaming phrase in all git repository commits (in submodules)
如何在git子模塊中為所有先前的提交重命名短語?
phrase1 to phrase2
我的短語在.pack文件中。 (我縮短了十六進制的.pack名稱):
$ grep -rnw . -e 'phrase1'
Binary file ./.git/modules/folder1/objects/pack/pack-6170d.pack matches
Binary file ./.git/modules/folder2/modules/objects/pack/pack-934ef.pack matches
Binary file ./.git/modules/folder2/objects/1b/2eeaa matches
Binary file ./.git/modules/folder2/objects/1e/92b8b matches
Binary file ./.git/objects/54/fcce26 matches
我嘗試在倉庫上運行BFG,但得到以下輸出:
java -jar bfg-1.13.0.jar -rt expression_file.txt /my_repo/
...
BFG aborting: No refs to update - no dirty commits found??
...
我嘗試使用“ --no-blob-protection”參數運行BFG,但得到的輸出相同:
...
BFG aborting: No refs to update - no dirty commits found??
...
我的expression_file.txt具有以下格式:
phrase1 ==> phrase2
我調查了使用“ git filter branch”的過程,但不確定使用哪個命令來重寫這些文件。
只是為了回答問題的git filter-branch
部分。 在所有.txt
文件中,可以使用phrase1
用phrase2
替換phrase1
:
git filter-branch -f --tree-filter '
find . -type f -name '*.txt' -exec sed -i 's/phrase1/phrase2/g' {} +
' --prune-empty --all
請注意,可能需要花費大量時間。 --all
選項將在所有分支中執行替換。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.