【问题标题】:Why has git-filter-branch not rewritten tags?为什么 git-filter-branch 没有重写标签?
【发布时间】:2011-10-06 10:14:10
【问题描述】:

我需要将我的 git repo 分成两部分。我使用了这里显示的步骤:Detach (move) subdirectory into separate Git repository

我使用的命令是:

 git filter-branch --subdirectory-filter ABC HEAD -- --all

这似乎工作正常,并让我以 ABC 作为根。

但是现在,如果我尝试签出在拆分 repo 之前存在的标签:

 git checkout an-old-tagname

它正在重新创建旧的目录结构 - 因此将 ABC 与 XYZ1 和 XYZ2 一起重新创建为子目录。

我知道这就是 repo 在那个时间点的真实看法——但我希望标签只引用 ABC 位,就好像它们当时在根目录中一样。我认为这就是 filter-branch 在重写历史时所做的事情,但显然我没有正确理解它。

我怎样才能重新编写标签,以便我可以回到过去,同时仍然让 ABC 成为 repo 的根?

【问题讨论】:

    标签: git git-filter-branch


    【解决方案1】:

    您需要指定

    --tag-name-filter cat
    

    也可以重写标签

    现在,你可以做

    git filter-branch --tag-name-filter cat ...其他过滤器选项...-- --tags

    其中 ...其他过滤器选项... 重复您之前应用的过滤器。

    【讨论】:

    • 我无法再次运行 --subdirectory-filter ,因为原来的子目录现在是根目录。有没有办法让我首先运行--subdirectory-filter ... --tag-name-filter cat -- --tags
    • 不,我希望您可以“再次”运行它,只要您针对标签运行它。还记得,标签是重写的吗?您在原始帖子中提到了自己
    • @MalcolmBox 我调整了你的调整。这样更好吗?
    猜你喜欢
    • 1970-01-01
    • 2021-05-19
    • 1970-01-01
    • 2020-02-20
    • 1970-01-01
    • 1970-01-01
    • 2013-11-07
    • 2013-03-29
    • 2020-07-22
    相关资源
    最近更新 更多