【问题标题】:Renaming phrase in all git repository commits (in submodules)在所有 git 存储库提交中重命名短语(在子模块中)
【发布时间】:2018-11-12 20:41:23
【问题描述】:

如何为我的 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

我尝试在 repo 上运行 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 bfg-repo-cleaner


    【解决方案1】:

    只是回答问题的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 选项将在所有分支中执行替换。

    【讨论】:

      猜你喜欢
      • 2023-04-02
      • 1970-01-01
      • 2011-06-29
      • 2022-10-06
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 2014-01-07
      • 2011-05-30
      相关资源
      最近更新 更多