8

I'm running a local git server, and I'm just wondering, is there a way to see all the pull-requests made by developers? Similar to Github or Bitbucket but in command line.

7 Answers 7

9

This small configuration change may help you achieve what you want.

1. Add the following line to your .git/config file fetch = +refs/pull/*/head:refs/remotes/origin/pr/*

2. Fetch all pull requests using : $ git fetch origin

3. To checkout a particular PR run : $ git checkout pr/999

There is a concise guide here

1
  • If you adjusted your config as prescribed by this answer, perhaps with something like git config --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*" ... and then trusted the PR-checkout to naturally setup the new local branch with something like git checkout pr/999 -- then you will have trouble trying to just git pull it again to get PR updates. The branch.pr/999.merge config value will not be correct. See here for how to address that issue.
    – CrashNeb
    Sep 13, 2022 at 21:38
6

git-request-pull doesn't send anything. It just prints to your terminal a text, that can be e-mailed to upstream repository owner.

As written in docs:

The request, printed to the standard output, begins with the branch description, summarizes the changes and indicates from where they can be pulled.

And in Git Book:

you can run the git request-pull command and email the output to the project maintainer manually

Example from that book:

$ git request-pull origin/master myfork
The following changes since commit 1edee6b1d61823a2de3b09c160d7080b8d1b3a40:
  John Smith (1):
        added a new function

are available in the git repository at:

  git://githost/simplegit.git featureA

Jessica Smith (2):
      add limit to log function
      change log output to 30 from 25

 lib/simplegit.rb |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
4

To list all pull requests:

git ls-remote origin 'pull/*/head'

acb088927f51e6b48c92eb8bffb5a17723260776 refs/pull/1/head cbd690b74526bb621446b169a8e1e1eae85b8901 refs/pull/2/head fc39e6b269f187ceeeefc8f71e6eaa95e6618786 refs/pull/3/head
...

To show information about specific PR:

git ls-remote origin 'pull/3/head' | awk '{print $1}' | xargs git show

(You can add | cat if the commit output is long).

Output example:

commit fc39e6b269f187ceeeefc8f71e6eaa95e6618786
Author: ...
Date: ...

add_test_subctl_benchmark

diff --git a/setup_subm.sh b/setup_subm.sh
index 1fce037..621336b 100755
...

3

All the above answers suggested modifying the .git/config file. If you don't want to change the git config file to list all the Pull requests you can use the following command

git fetch origin +refs/pull/*/head:refs/remotes/origin/pr/*
1
  • can you describe step-by-step what this does? Dec 18, 2022 at 7:23
2

You have lot of tools to view your git server statistics.

gitinspector for example is one of them. There are lot more where you can see statistics in a nice way.

There is a command for console which allows you to check commits by author. check this,

git shortlog -s -n 
2

Run this command to see all the pull request made by developers:

git shortlog -n

after running the command keep pressing enter to log the complete details.

2

There is a new official Github CLI released recently.

Install it with brew install gh, and then list Pull Requests with:

gh pr list

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.