Git - 重新定位到特定标签

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12469855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:30:52  来源:igfitidea点击:

Git - rebasing to a particular tag

gitrebasegit-rebasegit-tag

提问by MartyMacGyver

(This seems like it should be very easy to do, yet I'm coming up empty on searches so far.)

(这似乎应该很容易做到,但到目前为止我的搜索结果是空的。)

I have a body of code from an upstream source, with various versions tagged in it on various branches.

我有一个来自上游源的代码体,在各个分支上标记了各种版本。

I am working on my "develop" branch which was based on tag "v1.0". many versions have come out since then, but while "v2.0" is interesting, I want to rebase my develop branch to "v1.5" and continue working there (assume I don't plan to feed that back upstream). Maybe later I'll rebase it again to "v2.0".

我正在开发基于标签“v1.0”的“开发”分支。从那以后出现了许多版本,但虽然“v2.0”很有趣,但我想将我的开发分支重新设置为“v1.5”并继续在那里工作(假设我不打算将其反馈给上游)。也许稍后我会再次将其重新设置为“v2.0”。

(For this purpose assume "v1.x"s are all tags on the same branch. For extra credit we can assume "v2.0" is a tag on another branch.)

(为此,假设“v1.x”是同一个分支上的所有标签。为了额外的功劳,我们可以假设“v2.0”是另一个分支上的标签。)

I was able to create the initial "develop" branch based on the "v1.0" tag easily enough, but rebase appears to only work with branches. Can't one rebase using tags as well? If not, what's the right way to accomplish that (so as to have exactly the same effect as rebasing to a particular tag)?

我能够很容易地基于“v1.0”标签创建初始的“develop”分支,但 rebase 似乎只适用于分支。一个人不能也使用标签吗?如果不是,那么完成它的正确方法是什么(以便与重新定位到特定标签具有完全相同的效果)?

回答by Karl Bielefeldt

You would use the following command:

您将使用以下命令:

git rebase --onto v1.5 v1.0 develop

The developpart of the command must be a branch, but the other two can be whatever you want.

develop命令的一部分必须是一个分支,但其他两个可以是任何你想要的。