2013-04-10 56 views
1

我有一个项目,其中我的开发分支是2稳定分支之前的标签发布,但我想删除第一个标记的更改集(这是我不再想要的一系列功能),但将最新的标记更改(第二个标记)应用到稳定标记上。Git rebase的标签,而不是单独提交

例如:

提交:

[tag] 3.0 - 
sdaf213 Some Commit of the tag 3 
sdaas34 Some other commit in this tag 
[tag] 2.0 - 
wert78 Some commit of tag 2 
werg99 Another commit of tag 2 
werh55 And another of tag 2 
[tag] 1.0 (Stable) - 
pry77 Commits of tag 1 
...older commits 

有没有办法与git变基上的标签,而不是承诺,这样我可以变基的[标签顶部[标签] 3.0的所有提交] 1.0,但排除[标签] 2.0中的所有内容?

git rebase --onto 1.0 2.0 BRANCH 

哪里分公司要应用衍合你的分支的名字:

+0

标签_are_(标识符)提交。您几乎总是可以使用标签而不是SHA – Useless 2013-04-10 16:18:13

回答

3

你可以这样做只是。

这将使用1.0标签作为母公司,然后重播3.0标签的提交顺序:

sdaf213 Some Commit of the tag 3 
sdaas34 Some other commit in this tag 
1.0 (Stable) - 
pry77 Commits of tag 1 
...older commits 

正如你可以看到3.0标签将不会被重新应用到您的历史结束。你将不得不创建一个新的,虽然这是有道理的,因为历史已经改变,你可能想要使这个2.1或3.1,以满足您的需求。

此外,你可以通过一系列标签来使用它。例如,如果您现在在[tag] 4.0并且想要摆脱[tag] 2.0和3.0:

git rebase --onto 1.0 3.0 BRANCH