简体   繁体   中英

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. 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. 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.

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

A tag named master does not mean anything. But by the same token, the branch name master does not mean anything either. 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.

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. (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. Note that git checkout effectively prefers the branch though. That's why people get confused: they don't know whether master means refs/heads/master or 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. 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. In your example above, I believe the tooltip would say "Head for branch master".

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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