繁体   English   中英

在所有git仓库提交中重命名短语(在子模块中)

[英]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文件中,可以使用phrase1phrase2替换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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM