[英]Create a tag in a GitHub repository
I have a repository in GitHub and I need to tag it.我在 GitHub 中有一个存储库,我需要标记它。
I tagged in a shell, but on GitHub , it is not showing up.我标记了 shell,但在GitHub上,它没有显示。
Do I have to do anything else?我还需要做其他事情吗?
The command I used in the shell is:我在shell中使用的命令是:
git tag 2.0
And now when I type git tag
it shows:现在,当我输入git tag
标签时,它显示:
2.0
So it seems like tags are present, correct?所以看起来标签存在,对吗?
The repository is: https://github.com/keevitaja/myseo-pyrocms .存储库是: https://github.com/keevitaja/myseo-pyrocms 。
How do I make this tag show up on GitHub?如何让这个标签显示在 GitHub 上? Where are my tags?我的标签在哪里?
You can create tags for GitHub by either using:您可以使用以下任一方法为 GitHub 创建标签:
To create a tag on your current branch, run this:要在当前分支上创建标签,请运行以下命令:
git tag <tagname>
If you want to include a description with your tag, add -a
to create an annotated tag :如果要在标签中包含说明,请添加-a
以创建带注释的标签:
git tag <tagname> -a
This will create a local
tag with the current state of the branch you are on.这将使用您所在分支的当前状态创建一个local
标签。 When pushing to your remote repo, tags are NOT included by default.推送到远程仓库时,默认情况下不包含标签。 You will need to explicitly say that you want to push your tags to your remote repo:您需要明确说明要将标签推送到远程存储库:
git push origin --tags
From the official Linux Kernel Git documentation for git push
:来自git push
的 官方 Linux 内核 Git 文档:
--tags
All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the command line.除了在命令行中明确列出的 refspecs 之外,refs/tags 下的所有 refs 都会被推送。
Or if you just want to push a single tag:或者,如果您只想推送一个标签:
git push origin <tag>
See also my answer to How do you push a tag to a remote repository using Git?另请参阅我对如何使用 Git 将标签推送到远程存储库的回答? for more details about that syntax above.有关上述语法的更多详细信息。
You can find GitHub's instructions for this at their Creating Releases help page .您可以在其创建发布帮助页面 中找到 GitHub 对此的说明。 Here is a summary:这是一个总结:
Click the releases link on our repository page,单击我们存储库页面上的发布链接,
Click on Create a new release or Draft a new release ,单击Create a new release或Draft a new release ,
Fill out the form fields, then click Publish release at the bottom,填写表单字段,然后单击底部的发布版本,
After you create your tag on GitHub, you might want to fetch it into your local repository too:在 GitHub 上创建标签后,您可能还想将其提取到本地存储库中:
git fetch
Now next time, you may want to create one more tag within the same release from website.现在下一次,您可能希望在网站的同一版本中再创建一个标签。 For that follow these steps:为此,请执行以下步骤:
Go to release tab转到发布选项卡
Click on edit button for the release单击发布的编辑按钮
Provide name of the new tag ABC_DEF_V_5_3_T_2 and hit tab提供新标签 ABC_DEF_V_5_3_T_2 的名称并点击选项卡
After hitting tab, UI will show this message: Excellent!点击选项卡后,UI 将显示此消息:太好了! This tag will be created from the target when you publish this release.当您发布此版本时,将从目标创建此标记。 Also UI will provide an option to select the branch/commit UI 还将提供一个选项来选择分支/提交
Select branch or commit选择分支或提交
Check "This is a pre-release" checkbox for qa tag and uncheck it if the tag is created for Prod tag.选中 qa 标记的“这是预发布”复选框,如果标记是为 Prod 标记创建的,则取消选中它。
After that click on "Update Release"之后点击“更新版本”
This will create a new Tag within the existing Release.这将在现有版本中创建一个新标签。
Creating Tags创建标签
Git uses two main types of tags: lightweight and annotated . Git 使用两种主要类型的标签:轻量级和带注释的。
Annotated Tags :注释标签:
To create an annotated tag in Git you can just run the following simple commands on your terminal.要在 Git 中创建带注释的标签,您只需在终端上运行以下简单命令即可。
$ git tag -a v2.1.0 -m "xyz feature is released in this tag."
$ git tag
v1.0.0
v2.0.0
v2.1.0
The -m denotes message for that particular tag. -m 表示该特定标签的消息。 We can write summary of features which is going to tag here.我们可以在此处编写要标记的功能摘要。
Lightweight Tags :轻量级标签:
The other way to tag commits is lightweight tag.标记提交的另一种方法是轻量级标记。 We can do it in the following way:我们可以通过以下方式做到:
$ git tag v2.1.0
$ git tag
v1.0.0
v2.0.0
v2.1.0
Push Tag推送标签
To push particular tag you can use below command:要推送特定标签,您可以使用以下命令:
git push origin v1.0.3
Or if you want to push all tags then use the below command:或者,如果您想推送所有标签,请使用以下命令:
git push --tags
List all tags :列出所有标签:
To list all tags, use the following command.要列出所有标签,请使用以下命令。
git tag
You just have to push the tag after you run the git tag 2.0
command.你只需要在运行git tag 2.0
命令后推送标签。
So just do git push --tags
now.所以现在就做git push --tags
。
In case you want to tag a specific commit like i do如果你想像我一样标记一个特定的提交
Here's a command to do that :-这是执行此操作的命令:-
Example:例子:
git tag -a v1.0 7cceb02 -m "Your message here"
Where 7cceb02
is the beginning part of the commit id.其中7cceb02
是提交 ID 的开始部分。
You can then push the tag using git push origin v1.0
.然后,您可以使用git push origin v1.0
推送标签。
You can do git log
to show all the commit id's in your current branch.您可以执行git log
以显示当前分支中的所有提交 ID。
CAREFUL: In the command in Lawakush Kurmi's answer ( git tag -a v1.0
) the -a
flag is used.小心:在Lawakush Kurmi 的回答中的命令 ( git tag -a v1.0
) 中使用了-a
标志。 This flag tells Git to create an annotated flag.这个标志告诉 Git 创建一个带注释的标志。 If you don't provide the flag ( ie git tag v1.0
) then it'll create what's called a lightweight tag.如果您不提供标志( ie git tag v1.0
),那么它将创建所谓的轻量级标签。
Annotated tags are recommended, because they include a lot of extra information such as:建议使用带注释的标签,因为它们包含很多额外的信息,例如:
Because of this, you should always use annotated tags.因此,您应该始终使用带注释的标签。
It all depends what type of tag you want to create:这完全取决于您要创建的标签类型:
git tag -a v1.0.0
.如果要创建带注释的标签,以显示额外的元数据,可以通过以下方式进行: git tag -a v1.0.0
。git tag v1.0.0
.另一方面,轻量级标签用于“书签”您的提交以供私人使用: git tag v1.0.0
。There are a few other tag functionalities such as:还有一些其他标签功能,例如:
git tag -l -n3
.列出标签 - git tag -l -n3
。 The command lists all existing tags with maximum 3 lines of their tag message.该命令列出所有现有标签,最多 3 行标签消息。 By default -n only shows the first line.默认 -n 只显示第一行。git show <tag_identifier>
.标签详情 - git show <tag_identifier>
。 It shows all you need to know about a specific tag.它显示了您需要了解的有关特定标签的所有信息。git tag --sort=<type>
排序标签 - git tag --sort=<type>
git push origin v1.0
.发布标签 - git push origin v1.0
。 You can git push the tag individually, or you can run git push --tags which will push all tags at once.您可以单独 git push 标签,也可以运行 git push --tags 一次推送所有标签。Be sure to check this tag related article for more relevant information.请务必查看此标签相关文章以获取更多相关信息。
Here are the simple steps to create a GitHub Tag , when you release build from master.当您从 master 发布构建时,以下是创建 GitHub Tag的简单步骤。
Open source_tree tab开源_树选项卡
Right click on Tag sections from Tag which appear on left navigation section右键单击出现在左侧导航部分的 Tag 中的 Tag 部分
Click on New Tag()点击新标签()
Click on Add Tag from give name to tag (preferred version name of the code)单击从给定名称到标签的添加标签(代码的首选版本名称)
If you want to push the TAG on remote, while creating the TAG ref: step 5 which gives checkbox push TAG to origin check it and pushed tag appears on remote repository如果要在远程推送 TAG,在创建 TAG 引用时:第 5 步将复选框推送 TAG 到源检查它并推送标签出现在远程存储库上
In case while creating the TAG if you have forgotten to check the box Push to origin , you can do it later by right-clicking on the created TAG, click on Push to origin.如果在创建 TAG 时忘记选中Push to origin框,您可以稍后通过右键单击创建的 TAG,单击Push to origin 来完成。
For creating git tag you can simply run git tag <tagname>
command by replacing with the actual name of the tag.要创建 git 标签,您可以简单地运行git tag <tagname>
命令,替换为标签的实际名称。 Here is a complete tutorial on the basics of managing git tags: https://www.drupixels.com/blog/git-tags-create-push-remote-checkout-and-much-more以下是管理 git 标签基础知识的完整教程: https : //www.drupixels.com/blog/git-tags-create-push-remote-checkout-and-much-more
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.