在GitHub存储库中创建标记

本文翻译自: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? 我的标签在哪里?


#1楼

参考:https://stackoom.com/question/1ER4R/在GitHub存储库中创建标记


#2楼

You can create tags for GitHub by either using: 您可以使用以下命令为GitHub创建标记:

  • the Git command line, or Git命令行,或
  • GitHub's web interface. GitHub的网络界面。

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 : 如果要在标记中包含说明,请添加-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 Kernel Git文档中

 --tags 

All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the command line. 除了在命令行中明确列出的refspec之外,还会推送refs / tags下的所有引用。

Or if you just want to push a single tag: 或者,如果您只想推送单个标签:

git push origin <tag>

See also my answer to How to push a tag to a remote repository using Git? 另请参阅我如何使用Git将标签推送到远程存储库的答案 for more details about that syntax above. 有关上述语法的更多详细信息。

Creating tags through GitHub's web interface 通过GitHub的Web界面创建标签

You can find GitHub's instructions for this at their Creating Releases help page . 您可以在他们的创建版本帮助页面上找到GitHub的相关说明。 Here is a summary: 以下是摘要:

  1. Click the releases link on our repository page, 单击我们的存储库页面上的版本链接,

    截图1

  2. Click on Create a new release or Draft a new release , 单击“ 创建新版本”或“ 草拟新版本”

    截图2

  3. Fill out the form fields, then click Publish release at the bottom, 填写表单字段,然后单击底部的发布版本

    截图3截图4

  4. After you create your tag on GitHub, you might want to fetch it into your local repository too: 在GitHub上创建标记后,您可能还想将其提取到本地存储库中:

     git fetch 

#3楼

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


#4楼

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

#5楼

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: 建议使用带注释的标签,因为它们包含许多额外信息,例如:

  • the person who made the tag 制作标签的人
  • the date the tag was made 标签的制作日期
  • a message for the tag 标签的消息

Because of this, you should always use annotated tags. 因此,您应始终使用带注释的标签。


#6楼

It all depends what type of tag you want to create: 这一切都取决于您要创建的标签类型:

  • If you want to create Annotated tags, to show extra metadata, you can do it in the following way: git tag -a v1.0.0 . 如果要创建带注释的标签,要显示额外的元数据,可以通过以下方式执行: git tag -a v1.0.0
  • On the other hand, Lightweight tags are used to "bookmark" your commits for private use: git tag v1.0.0 . 另一方面,Lightweight标签用于“标记”您的提交供私人使用: git tag v1.0.0

There are a few other tag functionalities such as: 还有一些其他标记功能,例如:

  • Listing tags - 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仅显示第一行。
  • Tag details - git show <tag_identifier> . 标签详细信息 - git show <tag_identifier> It shows all you need to know about a specific tag. 它显示了您需要了解的有关特定标记的所有信息。
  • Sorting tags - git tag --sort=<type> 排序标签 - git tag --sort=<type>
  • Publishing tags - 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推送标签,或者你可以运行git push --tags,它会立即推送所有标签。

Be sure to check this tag related article for more relevant information. 请务必查看此标签相关文章以获取更多相关信息。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值