简体   繁体   English

Visual Studio 2019 中 Git 的主标记在历史上意味着什么?

[英]What does master tag mean in history for Git in Visual Studio 2019?

I am using Visual Studio 2019 Community Edition for an asp.net project with Azure DevOps Git as the source control.我正在将 Visual Studio 2019 社区版用于 Azure DevOps Git 作为源代码控制的 asp.net 项目。 I have been using this source control without issues for the past month.在过去的一个月里,我一直在使用这个源代码控制,没有任何问题。

But today, when I clicked on Commit and Push drop-down button in the Changes tab of Team Explorer then on viewing the history of project it showed a master tag for most recent commit/push that I had just made as shown in the screenshot below.但是今天,当我单击团队资源管理器的“更改”选项卡中的“提交和推送”下拉按钮时,然后在查看项目历史记录时,它显示了我刚刚制作的最近提交/推送的主标记,如下面的屏幕截图所示.

Visual Studio 2019 中 git 历史中的主标签

Question问题

Why did the master tag suddenly appear for most recent commit/push and what does it mean?为什么最近的提交/推送突然出现主标签,这是什么意思? I had not input any tag for this commit/push but this was added by Azure DevOps automatically.我没有为此提交/推送输入任何标签,但这是由 Azure DevOps 自动添加的。 Such a master tag never shows for any of the prior commits in the past month.这样的主标签在过去一个月的任何先前提交中都不会显示。

I have only 2 Git branches in my project - a local branch origin/master and a remote branch origin/master as in the screenshot below.我的项目中只有 2 个 Git 分支 - 一个本地分支origin/master和一个远程分支origin/master ,如下面的屏幕截图所示。

我的视觉工作室项目中的 git 分支

A tag named master does not mean anything.一个名为master的标签没有任何意义。 But by the same token, the branch name master does not mean anything either.但出于同样的原因,分支名称master也没有任何意义。 The meaning, if there is one, is whatever you think it is.意义,如果有的话,就是你认为的任何东西。

It's unwise to use the same name for a branch and a tag.对分支和标签使用相同的名称是不明智的。 Git handles this just fine, but humans get confused. Git处理得很好,但人类会感到困惑。

Lightweight tags have no additional information, but annotated tags record the person who creates them, in much the same way that commits record the person who creates them.轻量级标签没有额外的信息,但带注释的标签记录了创建它们的人,就像提交记录创建它们的人一样。 If this is an annotated tag, inspect it— git show refs/tags/master will do the trick for instance 1 —and then ask the person who created it what they thought they were doing and what name they'd like you to use instead, and then rename or delete the tag.如果这是一个带注释的标签,请检查它git show refs/tags/master会做到这一点,例如1 - 然后询问创建它的人他们认为他们在做什么以及他们希望你改用什么名称,然后重命名或删除标签。 (If the person turns out to be you, ask yourself why you did that. :-) ) (如果这个人原来是你,问问你自己为什么这样做。:-))


1 Actually, so will git show master : some Git commands, including git show , "prefer" the tag when it's ambiguous like this. 1实际上, git show master也是如此:一些 Git 命令,包括git show ,“首选”标签,当它像这样模棱两可时。 Note that git checkout effectively prefers the branch though.请注意, git checkout实际上更喜欢分支。 That's why people get confused: they don't know whether master means refs/heads/master or refs/tags/master .这就是人们感到困惑的原因:他们不知道master是指refs/heads/master还是refs/tags/master

This is not a tag.这不是标签。 It is letting you know that's the commit to which the master branch currently points.它让您知道这是主分支当前指向的提交。

The toolbar in the History window has three buttons on it where you can toggle seeing local branches, remote tracking branches, and tags labeled onto the corresponding commits. History window 中的工具栏上有三个按钮,您可以在其中切换查看本地分支、远程跟踪分支和标记到相应提交的标签。 By default, branches are rendered red and tags are green.默认情况下,分支呈现红色,标签呈现绿色。 Hovering the mouse over the label should also tell you if it's a branch or tag.将鼠标悬停在 label 上还应该告诉您它是分支还是标签。 In your example above, I believe the tooltip would say "Head for branch master".在你上面的例子中,我相信工具提示会说“Head for branch master”。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM