标签可以在 git filter-branch 和 rebase 之后自动移动吗?
编辑问题归结为“也可以指示git rebase
对标签进行rebase吗?”但对最初问题的回答也会有所帮助。
询问如何将过去添加到 git 存储库? 我遵循了这些说明。 <编辑>然后我重新调整基准以包含仅在快照中的文件,请参阅此处。</edit>由于历史被重写(通过 git filter-branch 或 git rebase 或两者?),所有标签仍然在原始时间线上*,我想以某种方式移动它们到新的。我认为我使所有带有标签的提交消息都是唯一的,因此我可以尝试编写一个使用它们的脚本,但更通用的 git move-tags
那么,有没有办法解决“新时间线上的 N 个提交之后,旧时间线上的第 N 个提交被标记”的问题?除了明显的手动重新标记之外,任何其他解决方案也都很棒。
(请随意将这个可怕的长句子改成简单的英语...)
*) 嘿,git 解决了祖父悖论!
edit The question boils down to "Can git rebase
be instructed to rebase tags, too?" But an answer to the original question would also help.
Asking How to prepend the past to a git repository? I followed these instructions. <edit>Then I rebased to include a file that was only in the snapshots, see here.</edit> Since history was rewritten (by git filter-branch
or git rebase
or both?) all tags are still on the original time line* and I'd somehow like to move them to the new one. I think I made all commit-messages with tags unique so I could try writing a script that uses them, but a more general git move-tags <from> <to>
would be better.
So, is there a way to address "the commit which is N commits after on the new timeline such that the Nth commit after on the old timeline is tagged "? Any other solution except the obvious manual retagging would also be great.
(please feel free to correct that horribly long sentence into plain English...)
*) hey, git solved the grandfather-paradox!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我写了一个脚本来执行此操作。
请参阅 gist.github.com/908381。
但更好的是,使用 git-filter-branch(1) 中内置的
--tag-name-filter
选项。I’ve written a script that does this.
See gist.github.com/908381.
But even better, use the
--tag-name-filter
option built into git-filter-branch(1).没有内置的方法可以使用 git 做你想做的事情。 “git rebase --tags”可能很有趣,但它不存在。
如果提交消息与您所说的相同,那么您可以遍历 refs/tags 中的每个标签,执行以下操作:
将提交消息与完整列表进行比较:
如果找到匹配项(并且 SHA1 哈希值不同),则执行以下操作:
There is no built in way to do what you want using git. 'git rebase --tags' might be interesting but it does not exist.
If the commit messages are identical as you say then you could go through each tag in refs/tags, do:
Compare the commit message to the full list:
If you find a match (and the SHA1 hash is different) then do:
有一种方法可以使用
--tag-name-filter
选项使git filter-branch
自动更新修改后的标签,如 在此答案中。There is a way to make
git filter-branch
automatically update modified tags using the--tag-name-filter
option, as described in this answer.根据 Thomas Rast 的说法,http://git.661346.n2。 nabble.com/Rebase-with-tags-td5582971.html:
According to Thomas Rast at http://git.661346.n2.nabble.com/Rebase-with-tags-td5582971.html:
我已经整理了自己的 python 实现,
git rebasetags
如果 rebase 是交互式的,您将看到一个 bash shell,您可以在其中进行更改。退出该 shell 后,标签将被恢复。
来自这篇文章
I have put together my own python implementation,
git rebasetags
In case the rebase is interactive, you will be presented with a bash shell where you can make the changes. Upon exiting that shell, the tags will be restored.
From this post