在标记版本之间重新建立基础,从而删除Git上的其他提交 [英] Rebasing between tagged versions removing other commits on Git
问题描述
我有一个项目由我自己(没有团队)进行.我已经标记了一些提交,例如v0.0.1
,v0.0.9
... v0.9.1
等.现在,我想重新设置它们的基础,只留下那些带有版本标记的提交,但是我有两个问题:
I have a project which I am working by myself (no team). I have tagged some commits like v0.0.1
, v0.0.9
...v0.9.1
and so on. Now, I would like to rebase them leaving only those version tagged commits, but I have two problems:
- 当我执行
git rebase -i v0.0.1
(第一个版本,此后已提交2000多个)时,我不知道如何在基准屏幕"(即定义壁球)中显示标签; - 即使我能够在rebase屏幕上看到标签,也要在2000次提交中手动定义压榨非常耗时;
- When I do
git rebase -i v0.0.1
(the first version, more than 2000 commits since then) I dont know how to show the tags inside the 'rebase screen', that is where I define squashs; - Even if I was be able to see the tags inside the rebase screen it would be so time consuming to define squashings manually on 2 thousand of commits;
这样做是正确的方法吗?有没有办法更快地实现目标?
Is the correct approach to do it? Is there a way to achieve that faster?
非常感谢您.
推荐答案
您不能在交互式rebase中获得标签,仅仅是因为标签是不可变的,并且rebase正在修改历史记录,因此是矛盾的.
You can't get the tags in interactive rebase, simply because tags are meant to be immutable, and rebase is modifying history, thus a contradiction.
交互基础也不是为了处理数千个提交而创建的,您必须使用文本编辑器的高级功能来解决它.
Interactive rebase isn't made neither for operating on thousands of commits, you have to cope with it by using advanced functions of your text editor.
您确定要压缩所有未标记的提交吗?即使您现在不感兴趣,也可以保留历史记录(当您想知道是什么提交引入了更改时,请考虑git blame
.
Are you sure you want to squash all your untagged commits? Even if you don't see interest now, it can be a great help to keep history (think git blame
when you want to know what commit introduced a change.
如果要查看标签历史记录,只需询问git log --tagged
.您可以简化历史记录,而无需更改回购记录的历史记录,这对您的项目来说很重要.
If you want to see tag history, you can just ask git log --tagged
. You get history simplification without altering your repo's history, which is precious to your project.
这篇关于在标记版本之间重新建立基础,从而删除Git上的其他提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!