为什么git-filter-branch不能重写标签? [英] Why has git-filter-branch not rewritten tags?
问题描述
我需要将我的git repo分成两部分。我使用这里显示的步骤:将子目录分离(移动)到单独的Git存储库
我使用的命令是:
git filter-branch --subdirectory-filter ABC HEAD - --all
这似乎工作正常
但是现在如果我尝试检出分割回购前存在的标签:
git checkout an-old-tagname
它重新创建旧的目录结构 - 所以重新创建ABC作为一个子目录,以及XYZ1和XYZ2。
我知道回购实际上是如何看待这个时间点的 - 但我希望这个标签只是指ABC字节,就好像它们当时在根部。我认为这就是过滤器分支在重写历史时所做的事情,但显然我没有正确理解它。
我怎样才能重写标签所以我可以回到过去,而仍然有ABC成为回购的根源?
你需要指定 - tag-name-filter cat
重写标签
现在,您可以做
lockquote
git filter-branch --tag-name-filter cat
...其他过滤选项... - --tags
其中 ...其他过滤选项... 重复您先前应用的过滤器。
I needed to split my git repo into two parts. I used the steps shown here: Detach (move) subdirectory into separate Git repository
The command I used was:
git filter-branch --subdirectory-filter ABC HEAD -- --all
which seemed to work fine and left me with ABC as the root.
However now if if I try to checkout a tag that existed before I split the repo:
git checkout an-old-tagname
it's recreating the old directory structure - so recreating ABC as a subdirectory, along with XYZ1 and XYZ2.
I know that is how the repo really looked at that point in time - but I want the tag to refer to just the ABC bits, as if they'd been at the root back then. I thought that's what filter-branch was doing when it re-wrote history, but obviously I don't grok it properly.
How can I get the tags re-written so I can go back in time while still having ABC be the root of the repo?
You need to specify
--tag-name-filter cat
to rewrite tags as well
Now, you could do
git filter-branch --tag-name-filter cat
...other filter options...-- --tags
where ...other filter options... repeats the filters you previously applied.
这篇关于为什么git-filter-branch不能重写标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!