0

So I have a list of commits SHAs to check. In a given commit SHA let's say 123ab45, I want to see if the commit is linked to a PR in the branch.

Is there any command that I can put to check that?

torek
  • 448,244
  • 59
  • 642
  • 775
appix
  • 29
  • 3

2 Answers2

3

This can be done with the GitHub CLI version 2.7 or above:

gh search prs 123ab45

This is also supported by the search functionality on github.com.

Enter at least the first seven characters of the commit SHA into the Pull Request search bar, or navigate directly to this URL:

https://github.com/your-repo/pulls?q=is%3Apr+123ab45+
TonyArra
  • 10,607
  • 1
  • 30
  • 46
2

git has no concept of "pull request". This is a feature that is added by services built on top of git such as Github, Bitbucket, Gitlab, etc. There is no git command to do what you ask. To do this you will need to use their tools and APIs. The exact solution here depends on which of these services you use.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • I know there is something called github cli. I once opened a PR on github with something like `gh pr create`. But I could not seem to figure out for this case with the given SHA – appix May 12 '22 at 20:21
  • @appix I should have asked which cloud service you use. Assuming you are using github, there is probably a way to do what you want with the github cli. I've never used it so can't provide any more suggestions than google its docs. – Code-Apprentice May 12 '22 at 21:58