如何在 Git 中的标签之间切换

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19791036/
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 09:18:31  来源:igfitidea点击:

How to switch between the tags in Git

git

提问by KhanUstaad

I am new to git. And I am facing problems while moving between the tags. I want to switch between the tags. Like if I have two versions. For example. version 1.0 version 2.0 so I want to move from version 2.0 to version 1.0 in Git.

我是 git 新手。我在标签之间移动时遇到了问题。我想在标签之间切换。就像我有两个版本一样。例如。版本 1.0 版本 2.0 所以我想在 Git 中从版本 2.0 移动到版本 1.0。

采纳答案by whaley

In git, a tag is given a name, which in git terminology is its reference. A tag in reality is more like an alias to a specific commit id (which is also a reference).

在 git 中,标签被赋予一个名称,在 git 术语中是它的引用。标签实际上更像是特定提交 id(这也是一个引用)的别名。

See http://git-scm.com/book/en/Git-Internals-Git-References

请参阅http://git-scm.com/book/en/Git-Internals-Git-References

So to switch between tags you would use the same technique that you would use to switch between other references such as branches or commits... git checkout <tagname>.

因此,要在标签之间切换,您将使用与在其他引用(例如分支或提交...)之间切换时使用的相同技术git checkout <tagname>

回答by Rahul Tripathi

You are probably looking for:

您可能正在寻找:

git checkout tag

git checkoutcan be used to checkout any commit and after that it can be used with a branch name to go back to a named branch.

git checkout可用于检出任何提交,之后它可以与分支名称一起使用以返回到命名分支。