Home > Software design >  How to find out from the git log who opened a pull request on GitHub
How to find out from the git log who opened a pull request on GitHub

Time:01-13

Is there a way to find out from the git log the person who opened the pull request on GitHub? I am not looking for the person who merged the pull request. I know that pull requests are not git feature but a GitHub feature. Maybe there is a way to find out after all.

git log --merges --first-parent

returns as "Author" the person who performed the merge.

CodePudding user response:

The only place git has to look for this is in the commits:

  • the original commits representing the change that was pushed to Github
  • the merge commit (assuming you use a true merge, not one of Github's history rewriting options)

For each of those, two names (and e-mail addresses) are recorded:

  • The author of the change
  • The committer of the change; for instance in a rebased commit, this is the person who ran git rebase

It's likely that one of these four will be who opened the Pull Request in Github's web UI, but there's no guarantee of it - if Bob opens a PR for Alice's change, and Carol merges it, only Alice and Carol will appear in the git log. Which is most likely depends on your workflow - the committer of the original change may be a reasonable guess, because they are the last one to "touch" the commits.

The only other way you have is to match the merge back to the closed Pull Request and use Github's proprietary APIs to look up the details there.

CodePudding user response:

When you know that commit X merged the pull request, you can use

git show X^2

to list the author of the last commit on the merged side-branch. That may be the one who opened the pull request.

That's no guarantee, just a good guess, because, as you say, pull requests are not a Git thing.

CodePudding user response:

As in BitBucket documentation, author is someone who initiated/created the pull request. Maybe it's same for github.

Link: https://confluence.atlassian.com/bitbucketserver/search-for-pull-requests-808488581.html

  •  Tags:  
  • Related