在 GitHub 存储库中创建标签 [英] Create a tag in a GitHub repository

查看:32
本文介绍了在 GitHub 存储库中创建标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 GitHub 中有一个存储库,我需要标记它.
我在 shell 中进行了标记,但在 GitHub 上,它没有显示出来.

我还需要做什么吗?

我在shell中使用的命令是:

git tag 2.0

现在当我输入 git tag 它显示:

2.0

所以看起来标签存在,对吗?

存储库是:https://github.com/keevitaja/myseo-pyrocms.

如何让这个标签显示在 GitHub 上?我的标签在哪里?

解决方案

您可以使用以下任一方式为 GitHub 创建标签:

  • Git 命令行,或
  • GitHub 的网络界面.

从命令行创建标签

要在当前分支上创建标签,请运行:

git tag 

如果您想在标签中包含说明,请添加 -a 以创建一个 带注释的标签:

git tag -一个

这将使用您所在分支的当前状态创建一个 local 标记.推送到远程仓库时,默认情况下不包含标签.您需要明确表示要将标签推送到远程存储库:

git push origin --tags

来自 官方 Linux 内核 Git 文档 git push:

<块引用>

--tags

除了在命令行中明确列出的 refspecs 之外,refs/tags 下的所有 refs 都会被推送.

或者如果你只想推送一个标签:

git push origin 

另见我对如何做的回答您是否使用 Git 将标签推送到远程存储库? 有关上述语法的更多详细信息.

通过 GitHub 的网络界面创建标签

您可以在他们的创建发布帮助页面中找到 GitHub 对此的说明.总结如下:

  1. 点击我们存储库页面上的发布链接,

  2. 点击创建新版本起草新版本

  3. 填写表单字段,然后点击底部的发布发布

  4. 在 GitHub 上创建标签后,您可能还想将其提取到本地存储库中:

    git fetch

现在,您可能希望在网站的同一版本中再创建一个标签.为此,请执行以下步骤:

转到发布标签

  1. 点击编辑按钮进行发布

  2. 提供新标签 ABC_DEF_V_5_3_T_2 的名称并点击标签

  3. 点击标签后,UI 将显示此消息:太棒了!当您发布此版本时,将从目标创建此标记.UI 还将提供一个选项来选择分支/提交

  4. 选择分支或提交

  5. 选中 qa 标记的这是预发布"复选框,如果标记是为 Prod 标记创建的,则取消选中它.

  6. 然后点击更新版本"

  7. 这将在现有版本中创建一个新标签.

I have a repository in GitHub and I need to tag it.
I tagged in a shell, but on GitHub, it is not showing up.

Do I have to do anything else?

The command I used in the shell is:

git tag 2.0

And now when I type git tag it shows:

2.0

So it seems like tags are present, correct?

The repository is: https://github.com/keevitaja/myseo-pyrocms.

How do I make this tag show up on GitHub? Where are my tags?

解决方案

You can create tags for GitHub by either using:

  • the Git command line, or
  • GitHub's web interface.

Creating tags from the command line

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:

git tag <tagname> -a

This will create a local tag with the current state of the branch you are on. 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:

--tags

All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the command line.

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? for more details about that syntax above.

Creating tags through GitHub's web interface

You can find GitHub's instructions for this at their Creating Releases help page. Here is a summary:

  1. Click the releases link on our repository page,

  2. Click on Create a new release or Draft a new release,

  3. Fill out the form fields, then click Publish release at the bottom,

  4. After you create your tag on GitHub, you might want to fetch it into your local repository too:

    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

  1. Click on edit button for the release

  2. Provide name of the new tag ABC_DEF_V_5_3_T_2 and hit tab

  3. After hitting tab, UI will show this message: Excellent! This tag will be created from the target when you publish this release. Also UI will provide an option to select the branch/commit

  4. Select branch or commit

  5. Check "This is a pre-release" checkbox for qa tag and uncheck it if the tag is created for Prod tag.

  6. After that click on "Update Release"

  7. This will create a new Tag within the existing Release.

这篇关于在 GitHub 存储库中创建标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆