iOi
iOi

Reputation: 413

Checking a pull request in bash

Say I have a repo in github, and someone issues a PR. It is there anyway to check if PR is made, and what is the difference with my origin branch using git from terminal?

Upvotes: 0

Views: 1673

Answers (2)

Chris
Chris

Reputation: 136936

GitHub's pull requests are built on top of Git's native refs system. As outlined in the GitHub help page checking out pull requests locally, it is possible to fetch pull requests to your local machine:

  1. Manually modify the .git/config file in your repository to add a new fetch line to whatever your GitHub remote is called (if you don't know, this is probably origin):

    [remote "origin"]
      url = [email protected]:<USERNAME>/<REPO_NAME>.git
      fetch = +refs/heads/*:refs/remotes/origin/*
    
      # Add this new line:
      fetch = +refs/pull/*/head:refs/pull/origin/*
    
  2. Now fetch from your remote:

    git fetch origin
    
  3. Check out a pull request:

    git checkout pull/origin/123
    

This will let you compile / test the pull request and decide if you wish to accept it using GitHub's web UI.

Upvotes: 3

choroba
choroba

Reputation: 241858

Check the commands pulls and pull-diff at https://github.com/ingydotnet/git-hub. It makes the GitHub API accessible easily from bash.

Upvotes: 1

Related Questions