简体   繁体   English

GitHub:包含特定提交的标签

[英]GitHub : Tags that include a specific commit

On Github, when you access the page corresponding to a commit - like this - you can see the following: 在Github上,当您访问与提交相对应的页面( 例如这样)时 ,您会看到以下内容:

提交页面

I imagine that next to the branch ( master ) the page is showing the repository tags that include that specific commit (in this case: 4.8.0, 4.7.1, 4.7.0, 4.6.2, 4.6.1 and 4.6.0 ). 我想象在分支( master )旁边,页面显示了包含该特定提交的存储库标签(在这种情况下: 4.8.0, 4.7.1, 4.7.0, 4.6.2, 4.6.14.6.0 )。

Is there a way to access that information through GitHub REST API, or through GIT command line tools? 是否可以通过GitHub REST API或GIT命令行工具访问该信息?

I'm not sure about the REST API, but you can do this from Git's CLI 我不确定REST API,但是您可以从Git的CLI执行此操作

git tag --contains <commit>

This will output all tags reachable from this commit. 这将输出此提交可访问的所有标签。 <commit> can be a commit or object... ie a branch name, tag name, or sha. <commit>可以是提交或对象...即分支名称,标记名称或sha。

Is there a way to access that information through GitHub REST API, or through GIT command line tools? 是否可以通过GitHub REST API或GIT命令行工具访问该信息?

You can get a list of all your tags in various ways. 您可以通过各种方式获取所有标签的列表。


GitHub API

Get a Tag 获取标签
GET /repos/:owner/:repo/git/tags/:sha

The response: 响应:

{
  "tag": "v0.0.1",
  "sha": "940bd336248efae0f9ee5bc7b2d5c985887b16ac",
  "url": "https://api.github.com/repos/octocat/Hello-World/git/tags/940bd336248efae0f9ee5bc7b2d5c985887b16ac",
  "message": "initial version\n",
  "tagger": {
    "name": "Scott Chacon",
    "email": "schacon@gmail.com",
    "date": "2014-11-07T22:01:45Z"
  },
  "object": {
    "type": "commit",
    "sha": "c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c",
    "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c"
  }
}

git log

git log --decorate --graph --oneline

在此处输入图片说明


git tag

git tag --contains <commit>

--contains [<commit>]
Only list tags which contain the specified commit (HEAD if not specified). 仅列出包含指定提交的标签(如果未指定,则为HEAD)。

在此处输入图片说明

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

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