Git:从PR获取分支名称 [英] Git: Getting a Branch Name from a PR

查看:104
本文介绍了Git:从PR获取分支名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继续按照本指南进行操作,以允许我按其PR编号签出分支机构而不是分支名称.

I went ahead and followed this guide to allow me to checkout branches by their PR number rather than the branch name.

但是,我想知道是否可能相反,允许我从命令行获取给定PR号的分支名称.可以吗?

However, I am wondering if the reverse is possible, allowing me to get the branch name given a PR number from the command line. Is it doable?

推荐答案

简短的回答是:没有映射(至少是GitHub通过面向Git的标准接口提供的)来显示拉取请求的目标分支.但是,所有的希望并没有失去! GitHub Pull Request API 可以为您提供现有的拉取请求: GET/repos/:owner /:repo /pulls/:number 返回相当大的请求具有所需信息的JSON Blob.

The short answer is no: there's no mapping (offered by GitHub by a standard Git-oriented interface, at least) showing the target branch of a pull request. However, all hope is not lost! The GitHub Pull Request API can give you the status of an existing pull request: GET /repos/:owner/:repo/pulls/:number returns a rather large JSON blob that has the required information.

请注意,解析此JSON blob需要其他工具.

Note that parsing this JSON blob requires additional tools.

这篇关于Git:从PR获取分支名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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