如何重命名git子模块中所有先前提交的短语?
phrase1 to phrase2
我的短语在.back文件中找到。(我缩短了十六进制的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
:
git filter-branch -f --tree-filter '
find . -type f -name '*.txt' -exec sed -i 's/phrase1/phrase2/g' {} +
' --prune-empty --all
请注意,这可能是一个非常耗时的难题。--all
选项将在所有分支中执行替换。