Question

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?

Était-ce utile?

La solution

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 = git@github.com:<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.

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top