Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub - Find the pull request associated with a commit

Tags:

git

github

I'm trying to find a past pull request to see which comments / actions were made on a particular issue.

I know the file and the change, so I can get to the commit that introduced it by looking at the blame view. However I can't find a way to look at the pull request that pushed that commit to the branch for the first time.

Is there a way to do this? Or do I have to go on a trip down memory lane and manually browse through past pull requests?

like image 333
Zepee Avatar asked Mar 10 '16 11:03

Zepee


People also ask

How do you get pull request from commit?

You can just go to GitHub and enter the SHA into the search bar, make sure you select the "Issues" link on the left. Via the GitHub UI there is a now a really easy way to do this. If you are looking at a commit in the list of commits in a branch in the UI, click on the link to the commit itself.

How do I find a specific pull request on GitHub?

Open TerminalTerminalGit Bash. Fetch the reference to the pull request based on its ID number, creating a new branch in the process. At this point, you can do anything you want with this branch. You can run some local tests, or merge other branches into the branch.

How do I get my GitHub pull request link?

The issue and pull request must be in the same repository. On GitHub.com, navigate to the main page of the repository. Under your repository name, click Pull requests. In the list of pull requests, click the pull request that you'd like to link to an issue.


2 Answers

You can filter your pull requests based on the commit SHA - see here

If you know the specific SHA hash of a commit, you can use it to search for pull requests that contain that SHA. Note that the SHA syntax must be at least seven characters.

For example:

e1109ab Matches pull requests with a commit SHA that starts with e1109ab.

0eff326d6213c is:merged Matches merged pull requests with a commit SHA that starts with 0eff326d6213c.

like image 138
James Bateson Avatar answered Oct 21 '22 16:10

James Bateson


GitHub has recently added an easier way to do this to their GraphQL API: https://developer.github.com/v4/changelog/2019-03-08-schema-changes/.

Here's an example query which demonstrates how to fetch associated pull requests of the five latest commits on the master branch:

{
  repository(name: "react", owner: "facebook") {
    ref(qualifiedName: "master") {
      target {
        ... on Commit {
          id
          history(first: 5) {
            nodes {
              id
              associatedPullRequests(first: 10) {
                edges {
                  node {
                    title
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
like image 36
Timon Avatar answered Oct 21 '22 16:10

Timon