Git:如何将带标签的修订版拉入我的 fork?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1357086/
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
Git: How do I pull a tagged revision into my fork?
提问by Jon Kruger
I have a fork of a project on github where the main trunk was recently tagged. I want to pull the code from the tagged revision into my fork. How would I do that?
我在 github 上有一个项目的分支,其中最近标记了主干。我想将标记修订版中的代码提取到我的 fork 中。我该怎么做?
回答by Michael Krelin - hacker
Once you have the tag in local repository you can do something like
在本地存储库中拥有标签后,您可以执行以下操作
git merge tags/yourtag
git merge tags/yourtag
If you don't have the "trunk" tags locally, you can fetch it using
如果您在本地没有“trunk”标签,您可以使用
git fetch remote-url "refs/tags/*:refs/tags/*"
git fetch remote-url "refs/tags/*:refs/tags/*"
Or by setting up the remote
或者通过设置遥控器
git remote add upstream remote-url
git remote add upstream remote-url
and fetching the stuff using
并使用
git fetch -t upstream
git fetch -t upstream
I think, though, using
我认为,不过,使用
git remote update
git remote update
will have similar effect.
会有类似的效果。
回答by Adam Florin
I may be projecting, but I think Jon's problem was the same as mine:
我可能在预测,但我认为 Jon 的问题和我的一样:
I forked someone else's project (on GitHub), and needed to point the masterbranch of my fork to a specific tagof their project, effectively ignoring all subsequent development. (Why? After that tag, their project dropped functionality that my fork depends on and must build on. So I'm pegged to that moment in history. Sad but true.)
我分叉了其他人的项目(在 GitHub 上),并且需要将我的分叉的master分支指向他们项目的特定标签,从而有效地忽略了所有后续开发。(为什么?在那个标签之后,他们的项目放弃了我的 fork 所依赖并且必须建立的功能。所以我与历史上的那个时刻挂钩。悲伤但真实。)
In this example, the tag was called 0.6.3
. All I had to do was cd
to my local clone (of my fork) and do
在这个例子中,标签被称为0.6.3
。我所要做的就是cd
到我的本地克隆(我的叉子)然后做
git reset --hard 0.6.3
git push --force
Then I verified on GitHub that my fork reflected the state of the code at their tag!
然后我在 GitHub 上验证我的 fork 反映了他们标签上的代码状态!